Skip to content

Commit

Permalink
Merge pull request #26 from ToastedDev/dev
Browse files Browse the repository at this point in the history
feat: move to nextjs and turborepo
  • Loading branch information
GalvinPython authored Jul 21, 2024
2 parents e371114 + 99395c0 commit 2ed6546
Show file tree
Hide file tree
Showing 59 changed files with 13,702 additions and 77 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
.env
.env
.turbo
21 changes: 21 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "@chatr/api",
"type": "module",
"version": "0.1.0",
"scripts": {
"dev": "bun with-env bun --watch src/index.ts --dev",
"with-env": "dotenv -e ../.env --"
},
"dependencies": {
"cors": "^2.8.5",
"ejs": "^3.1.10",
"express": "^4.19.2",
"mysql2": "^3.10.3"
},
"devDependencies": {
"@types/bun": "latest",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"dotenv-cli": "^7.4.2"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
46 changes: 0 additions & 46 deletions bot/index.ts

This file was deleted.

20 changes: 20 additions & 0 deletions bot/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "@chatr/bot",
"type": "module",
"version": "0.1.0",
"scripts": {
"dev": "bun with-env bun --watch src/index.ts --dev",
"with-env": "dotenv -e ../.env --"
},
"dependencies": {
"canvacord": "^6.0.2",
"colorthief": "^2.4.0",
"discord.js": "^14.15.3"
},
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
54 changes: 54 additions & 0 deletions bot/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Check if DISCORD_TOKEN has been provided as an environment variable, and is a valid regex pattern
const discordToken: string | undefined = process.argv.includes("--dev")
? process.env?.DISCORD_TOKEN_DEV
: process.env?.DISCORD_TOKEN;

if (!discordToken || discordToken === "YOUR_TOKEN_HERE")
throw "You MUST provide a discord token in .env!";

// If it has, run the bot
import {
Client,
GatewayIntentBits,
REST,
Routes,
type APIApplicationCommand,
} from "discord.js";
import commandsMap from "./commands";
import fs from "fs/promises";
import path from "path";

const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});

// Update the commands
console.log(`Refreshing ${commandsMap.size} commands`);
const rest = new REST().setToken(discordToken);
const getAppId: { id?: string | null } = (await rest.get(
Routes.currentApplication(),
)) || { id: null };
if (!getAppId?.id)
throw "No application ID was able to be found with this token";

const data = (await rest.put(Routes.applicationCommands(getAppId.id), {
body: [...commandsMap.values()].map((a) => {
return a.data;
}),
})) as APIApplicationCommand[];

console.log(`Successfully reloaded ${data.length} application (/) commands.`);

client.login(discordToken);

export default client;

// Import events
const getEvents = await fs.readdir(path.join(process.cwd(), "src/events"));
for await (const file of getEvents) {
await import("./events/" + file);
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified bun.lockb
Binary file not shown.
3 changes: 3 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import eslint from "@eslint/js";
import tseslint from "typescript-eslint";

export default tseslint.config(
{
ignores: ["web/.next"],
},
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
Expand Down
55 changes: 25 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
{
"name": "xpbot",
"type": "module",
"version": "0.1.0",
"scripts": {
"dev:api": "bun --watch api/index.ts --dev",
"dev:bot": "bun --watch bot/index.ts --dev",
"api": "bun api/index.ts",
"bot": "bun bot/index.ts",
"lint": "eslint . --config eslint.config.mjs"
},
"devDependencies": {
"@eslint/js": "^9.7.0",
"@types/bun": "latest",
"@types/cors": "^2.8.17",
"@types/eslint__js": "^8.42.3",
"@types/express": "^4.17.21",
"typescript-eslint": "^7.16.1"
},
"peerDependencies": {
"typescript": "^5.0.0"
},
"dependencies": {
"canvacord": "^6.0.2",
"colorthief": "^2.4.0",
"cors": "^2.8.5",
"discord.js": "^14.15.3",
"ejs": "^3.1.10",
"express": "^4.19.2",
"mysql2": "^3.10.3"
}
"name": "@chatr/root",
"type": "module",
"version": "0.1.0",
"packageManager": "bun@1.1.20",
"workspaces": [
"api",
"bot",
"web"
],
"scripts": {
"dev": "turbo run dev",
"lint": "eslint . --config eslint.config.mjs"
},
"dependencies": {},
"devDependencies": {
"@eslint/js": "^9.7.0",
"@types/bun": "latest",
"@types/eslint__js": "^8.42.3",
"dotenv-cli": "^7.4.2",
"turbo": "^2.0.9",
"typescript-eslint": "^7.16.1"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
13 changes: 13 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://turbo.build/schema.json",
"tasks": {
"dev": {
"persistent": true,
"cache": false
},
"build": {
"dependsOn": ["^build"],
"outputs": [".next/**", "!.next/cache/**"]
}
}
}
35 changes: 35 additions & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
3 changes: 3 additions & 0 deletions web/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"typescript.tsdk": "node_modules/typescript/lib"
}
3 changes: 3 additions & 0 deletions web/.vscode/settings.json:Zone.Identifier
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=C:\Users\ToastedToast\Downloads\next-pages-template-d32cd8f85a606260bd82868a585e6fb24f44c343.zip
21 changes: 21 additions & 0 deletions web/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Next UI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Next.js & NextUI Template

This is a template for creating applications using Next.js 13 (pages directory) and NextUI (v2).

## Technologies Used

- [Next.js 13](https://nextjs.org/docs/getting-started)
- [NextUI](https://nextui.org)
- [Tailwind CSS](https://tailwindcss.com)
- [Tailwind Variants](https://tailwind-variants.org)
- [TypeScript](https://www.typescriptlang.org)
- [Framer Motion](https://www.framer.com/motion)
- [next-themes](https://github.com/pacocoursey/next-themes)

## How to Use

To create a new project based on this template using `create-next-app`, run the following command:

```bash
npx create-next-app -e https://github.com/nextui-org/next-pages-template
```
## License

Licensed under the [MIT license](https://github.com/nextui-org/next-pages-template/blob/main/LICENSE).
12 changes: 12 additions & 0 deletions web/components/counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { useState } from "react";
import { Button } from "@nextui-org/react";

export const Counter = () => {
const [count, setCount] = useState(0);

return (
<Button radius="full" onPress={() => setCount(count + 1)}>
Count is {count}
</Button>
);
};
Loading

0 comments on commit 2ed6546

Please sign in to comment.