Skip to content

refactor: split shared into packages #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 38 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9697ca9
refactor: split shared into packages
tomast1337 Jul 25, 2025
b4ecf42
refactor: moved backend to packages
tomast1337 Jul 25, 2025
f79dc4e
refactor: moved frontend to apps/frontend
tomast1337 Jul 25, 2025
ff0be9d
refactor: restructure project to use workspaces for apps and packages
tomast1337 Jul 25, 2025
f350b50
refactor: clean up database module by removing unused index file and …
tomast1337 Jul 25, 2025
a2f54b6
refactor: update imports to use centralized database module and remov…
tomast1337 Jul 25, 2025
bee7b71
feat: implement offscreen drawing of notes and canvas swapping functi…
tomast1337 Jul 25, 2025
baa803c
refactor: update imports to use centralized module paths and clean up…
tomast1337 Jul 25, 2025
e6834bc
refactor: tidy up tsconfig.json formatting for improved readability
tomast1337 Jul 25, 2025
91b480b
refactor: update imports to use centralized database module and clean…
tomast1337 Jul 26, 2025
f8697f6
refactor: update build and start scripts to reflect new package struc…
tomast1337 Jul 26, 2025
4e44766
refactor: update ESLint configuration paths to reflect new directory …
tomast1337 Jul 26, 2025
7928d51
refactor: update imports to use new package structure for sounds and …
tomast1337 Jul 26, 2025
4d29bce
refactor: add test script to package.json and update imports for cons…
tomast1337 Jul 26, 2025
0785bd5
refactor: standardize import statements across multiple files and cle…
tomast1337 Jul 26, 2025
e76df8f
refactor: add lint and test scripts to package.json for database, son…
tomast1337 Jul 26, 2025
52520ec
refactor: update test scripts in package.json for backend, database, …
tomast1337 Jul 26, 2025
f4a8ca3
chore: add docker-compose.yml to configure MongoDB, Maildev, MinIO, a…
tomast1337 Aug 12, 2025
9d0a1b7
refactor: remove unused import in SongDetails component for cleaner code
tomast1337 Aug 12, 2025
f1588b6
feat: initialize configs package with basic structure, including Type…
tomast1337 Aug 13, 2025
24bab36
refactor: rename packages and update package.json structure to reflec…
tomast1337 Aug 13, 2025
7419f74
refactor: remove unused colors export from thumbnail package for clea…
tomast1337 Aug 13, 2025
10e468a
feat: add development script to sounds package for watch mode during …
tomast1337 Aug 13, 2025
1867009
refactor: update imports to use new constants from @nbw/config for co…
tomast1337 Aug 13, 2025
4d4cca6
refactor: standardize import statements and update to use UPLOAD_CONS…
tomast1337 Aug 13, 2025
e60fbc4
feat: add Bun configuration rule to replace Node.js and related tools…
tomast1337 Aug 13, 2025
212b52e
refactor: update components to use UPLOAD_CONSTANTS and other new con…
tomast1337 Aug 13, 2025
374c7c8
refactor: update data directory path in build script to align with ne…
tomast1337 Aug 13, 2025
59ff35c
refactor: move backend to apps/backend
tomast1337 Aug 13, 2025
d670b34
fix: Tests are no longer run and included in the dist folder
tomast1337 Aug 13, 2025
1ea8531
refactor: update thumbnail package.json to support separate builds fo…
tomast1337 Aug 13, 2025
814b19b
refactor: update song package.json to support separate build scripts …
tomast1337 Aug 13, 2025
4d71486
refactor: enhance canvasFactory to support both Node.js and browser e…
tomast1337 Aug 13, 2025
4a30be5
refactor: update VSCode settings and enhance SongThumbnailInput compo…
tomast1337 Aug 14, 2025
118a2c7
refactor: remove unnecessary whitespace in auth.module.ts and seed.se…
tomast1337 Aug 14, 2025
b7b31cd
refactor: reorganize workspace structure and update VSCode settings f…
tomast1337 Aug 14, 2025
95ac61a
refactor: add missing import for MailingModule in auth.module.ts to e…
tomast1337 Aug 14, 2025
e72bc86
Update build.ts
tomast1337 Aug 14, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
111 changes: 111 additions & 0 deletions .cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
description: Use Bun instead of Node.js, npm, pnpm, or vite.
globs: "*.ts, *.tsx, *.html, *.css, *.js, *.jsx, package.json"
alwaysApply: false
---

Default to using Bun instead of Node.js.

- Use `bun <file>` instead of `node <file>` or `ts-node <file>`
- Use `bun test` instead of `jest` or `vitest`
- Use `bun build <file.html|file.ts|file.css>` instead of `webpack` or `esbuild`
- Use `bun install` instead of `npm install` or `yarn install` or `pnpm install`
- Use `bun run <script>` instead of `npm run <script>` or `yarn run <script>` or `pnpm run <script>`
- Bun automatically loads .env, so don't use dotenv.

## APIs

- `Bun.serve()` supports WebSockets, HTTPS, and routes. Don't use `express`.
- `bun:sqlite` for SQLite. Don't use `better-sqlite3`.
- `Bun.redis` for Redis. Don't use `ioredis`.
- `Bun.sql` for Postgres. Don't use `pg` or `postgres.js`.
- `WebSocket` is built-in. Don't use `ws`.
- Prefer `Bun.file` over `node:fs`'s readFile/writeFile
- Bun.$`ls` instead of execa.

## Testing

Use `bun test` to run tests.

```ts#index.test.ts
import { test, expect } from "bun:test";

test("hello world", () => {
expect(1).toBe(1);
});
```

## Frontend

Use HTML imports with `Bun.serve()`. Don't use `vite`. HTML imports fully support React, CSS, Tailwind.

Server:

```ts#index.ts
import index from "./index.html"

Bun.serve({
routes: {
"/": index,
"/api/users/:id": {
GET: (req) => {
return new Response(JSON.stringify({ id: req.params.id }));
},
},
},
// optional websocket support
websocket: {
open: (ws) => {
ws.send("Hello, world!");
},
message: (ws, message) => {
ws.send(message);
},
close: (ws) => {
// handle close
}
},
development: {
hmr: true,
console: true,
}
})
```

HTML files can import .tsx, .jsx or .js files directly and Bun's bundler will transpile & bundle automatically. `<link>` tags can point to stylesheets and Bun's CSS bundler will bundle.

```html#index.html
<html>
<body>
<h1>Hello, world!</h1>
<script type="module" src="./frontend.tsx"></script>
</body>
</html>
```

With the following `frontend.tsx`:

```tsx#frontend.tsx
import React from "react";

// import .css files directly and it works
import './index.css';

import { createRoot } from "react-dom/client";

const root = createRoot(document.body);

export default function Frontend() {
return <h1>Hello, world!</h1>;
}

root.render(<Frontend />);
```

Then, run index.ts

```sh
bun --hot ./index.ts
```

For more information, read the Bun API docs in `node_modules/bun-types/docs/**.md`.
40 changes: 31 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
{
"editor.formatOnSave": true,
"eslint.validate": ["typescript"],
"eslint.run": "onType",
"eslint.format.enable": true,
"mdx.server.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
}
}
"editor.formatOnSave": true,
"eslint.validate": [
"typescript"
],
"eslint.run": "onType",
"eslint.format.enable": true,
"mdx.server.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#fac977",
"activityBar.background": "#fac977",
"activityBar.foreground": "#15202b",
"activityBar.inactiveForeground": "#15202b99",
"activityBarBadge.background": "#069a62",
"activityBarBadge.foreground": "#e7e7e7",
"commandCenter.border": "#15202b99",
"sash.hoverBorder": "#fac977",
"statusBar.background": "#f8b646",
"statusBar.foreground": "#15202b",
"statusBarItem.hoverBackground": "#f6a315",
"statusBarItem.remoteBackground": "#f8b646",
"statusBarItem.remoteForeground": "#15202b",
"titleBar.activeBackground": "#f8b646",
"titleBar.activeForeground": "#15202b",
"titleBar.inactiveBackground": "#f8b64699",
"titleBar.inactiveForeground": "#15202b99"
},
"peacock.color": "#f8b646"
}
107 changes: 72 additions & 35 deletions NoteBlockWorld.code-workspace
Original file line number Diff line number Diff line change
@@ -1,37 +1,74 @@
{
"folders": [
{
"path": ".",
"name": "Root"
},
{
"path": "./server",
"name": "Backend"
},
{
"path": "./shared",
"name": "Shared"
},
{
"path": "./web",
"name": "Frontend"
"folders": [
{
"path": ".",
"name": "Root"
},
{
"path": "./apps/backend",
"name": "Backend"
},
{
"path": "./apps/frontend",
"name": "Frontend"
},
{
"path": "./packages/configs",
"name": "configs"
},
{
"path": "./packages/database",
"name": "database"
},
{
"path": "./packages/song",
"name": "song"
},
{
"path": "./packages/sounds",
"name": "sounds"
},
{
"path": "./packages/thumbnail",
"name": "thumbnail"
},
],
"settings": {
"window.title": "${dirty}${rootName}${separator}${profileName}${separator}${appName}",
"editor.formatOnSave": true,
"eslint.validate": [
"typescript"
],
"eslint.run": "onType",
"eslint.format.enable": true,
"mdx.server.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/dist": true,
},
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#2ab333",
"activityBar.background": "#2ab333",
"activityBar.foreground": "#e7e7e7",
"activityBar.inactiveForeground": "#e7e7e799",
"activityBarBadge.background": "#e6e5f9",
"activityBarBadge.foreground": "#15202b",
"commandCenter.border": "#e7e7e799",
"sash.hoverBorder": "#2ab333",
"statusBar.background": "#208a27",
"statusBar.foreground": "#e7e7e7",
"statusBarItem.hoverBackground": "#2ab333",
"statusBarItem.remoteBackground": "#208a27",
"statusBarItem.remoteForeground": "#e7e7e7",
"titleBar.activeBackground": "#208a27",
"titleBar.activeForeground": "#e7e7e7",
"titleBar.inactiveBackground": "#208a2799",
"titleBar.inactiveForeground": "#e7e7e799"
},
"peacock.color": "#208a27"
}
],
"settings": {
"window.title": "${dirty}${rootName}${separator}${profileName}${separator}${appName}",
"editor.formatOnSave": true,
"eslint.validate": ["typescript"],
"eslint.run": "onType",
"eslint.format.enable": true,
"mdx.server.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit"
},
"jest.disabledWorkspaceFolders": ["Root", "Frontend"],
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/dist": true,
}
}
}
}
File renamed without changes.
2 changes: 1 addition & 1 deletion server/.eslintrc.json → apps/backend/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": [
"../.eslintrc.js"
"../../.eslintrc.js"
],
"root": true,
"env": {
Expand Down
3 changes: 3 additions & 0 deletions server/.gitignore → apps/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
.env.development
.env.production
dist
coverage
*.log
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 10 additions & 6 deletions server/package.json → apps/backend/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "noteblockworld-server",
"name": "@nbw/backend",
"version": "0.0.1",
"description": "",
"author": "",
Expand All @@ -15,11 +15,11 @@
"start:debug": "NODE_ENV=development tsc-watch --onSuccess \"bun . --inspect\"",
"start:prod": "NODE_ENV=production bun dist/main.js",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "bun test",
"test:watch": "bun test --watch",
"test:cov": "bun test --coverage",
"test": "bun test src/**/*.spec.ts",
"test:watch": "bun test src/**/*.spec.ts --watch",
"test:cov": "bun test src/**/*.spec.ts --coverage",
"test:debug": "bun --inspect-brk --runInBand",
"test:e2e": "bun test ./test/app.e2e-spec.ts"
"test:e2e": "bun test e2e/**/*.spec.ts"
},
"dependencies": {
"@aws-sdk/client-s3": "3.717.0",
Expand Down Expand Up @@ -56,7 +56,11 @@
"rxjs": "^7.8.1",
"uuid": "^9.0.1",
"zod": "^3.24.1",
"zod-validation-error": "^3.4.0"
"zod-validation-error": "^3.4.0",
"@nbw/database": "workspace:*",
"@nbw/song": "workspace:*",
"@nbw/thumbnail": "workspace:*",
"@nbw/sounds": "workspace:*"
},
"devDependencies": {
"@faker-js/faker": "^9.3.0",
Expand Down
Loading
Loading