switch compiler to swc, add eslint
This commit is contained in:
parent
9f74db9857
commit
42f48fb046
13 changed files with 1422 additions and 144 deletions
1
.eslintignore
Normal file
1
.eslintignore
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
20
.eslintrc.json
Normal file
20
.eslintrc.json
Normal file
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"env": {
|
||||
"es2021": true,
|
||||
"node": true
|
||||
},
|
||||
"extends": [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/recommended"
|
||||
],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": [
|
||||
"@typescript-eslint"
|
||||
],
|
||||
"rules": {
|
||||
}
|
||||
}
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,3 +1,3 @@
|
|||
node_modules/
|
||||
build/
|
||||
dist/
|
||||
.env
|
||||
|
|
1
.prettierignore
Normal file
1
.prettierignore
Normal file
|
@ -0,0 +1 @@
|
|||
build/
|
19
.swcrc
Normal file
19
.swcrc
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": false,
|
||||
"decorators": true,
|
||||
"dynamicImport": true
|
||||
},
|
||||
"target": "es2020",
|
||||
"paths": {
|
||||
"~/*": ["./src/*"],
|
||||
"~entities/*": ["./src/db/entities/*"]
|
||||
},
|
||||
"baseUrl": "."
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
}
|
||||
}
|
20
README.md
20
README.md
|
@ -1 +1,21 @@
|
|||
# Mercury
|
||||
|
||||
ActivityPub server implementation (hopefully, eventually),
|
||||
currently mostly a way for me to play around with writing an API server in TypeScript.
|
||||
|
||||
## Configuration
|
||||
|
||||
For now, check out `src/config.ts`, the names should be mostly self explanatory.
|
||||
Consider all environment variables required.
|
||||
|
||||
## Development commands
|
||||
|
||||
- Building the server: `pnpm build`
|
||||
- Migrating the database: `pnpm migrate`
|
||||
- Watching for changes and reloading the server automatically: `pnpm dev`
|
||||
- Formatting: `pnpm format`
|
||||
- Linting (if you don't have an ESLint plugin): `pnpm format`
|
||||
|
||||
## License
|
||||
|
||||
Mercury is licensed under the GNU Affero General Public License, version 3 **only**.
|
||||
|
|
16
package.json
16
package.json
|
@ -8,8 +8,12 @@
|
|||
"license": "AGPL-3.0-only",
|
||||
"main": "dist/index.js",
|
||||
"scripts": {
|
||||
"dev": "nodemon ./src/index.ts",
|
||||
"build": "tsc",
|
||||
"dev": "concurrently \"pnpm watch:build\" \"pnpm watch:dev\"",
|
||||
"build": "swc src -d dist",
|
||||
"watch:build": "swc src -w --out-dir dist",
|
||||
"watch:dev": "nodemon --watch \"dist/**/*\" -e js ./dist/index.js",
|
||||
"format": "prettier -w",
|
||||
"lint": "eslint src/",
|
||||
"typeorm": "typeorm-ts-node-esm",
|
||||
"migrate": "typeorm-ts-node-esm migration:run -d ./src/db/index.ts"
|
||||
},
|
||||
|
@ -26,10 +30,16 @@
|
|||
"ulid": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@swc/cli": "^0.1.62",
|
||||
"@swc/core": "^1.3.70",
|
||||
"@types/express": "^4.17.17",
|
||||
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
||||
"@typescript-eslint/parser": "^6.1.0",
|
||||
"chokidar": "^3.5.3",
|
||||
"concurrently": "^8.2.0",
|
||||
"eslint": "^8.45.0",
|
||||
"nodemon": "^3.0.1",
|
||||
"prettier": "^3.0.0",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "5.1.6"
|
||||
}
|
||||
}
|
||||
|
|
1460
pnpm-lock.yaml
1460
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
import { ulid } from "ulid";
|
||||
import { hash } from "argon2";
|
||||
|
||||
import { Account } from "./entities/account.js";
|
||||
import { Account } from "~entities/account.js";
|
||||
import MercuryDataSource from "./index.js";
|
||||
|
||||
const missingAuthData = new Error("missing auth data for local user");
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { ulid } from "ulid";
|
||||
|
||||
import { Account } from "./entities/account.js";
|
||||
import { Blog } from "./entities/blog.js";
|
||||
import { Account } from "~entities/account.js";
|
||||
import { Blog } from "~entities/blog.js";
|
||||
import { generateKeyPair } from "./util/rsa.js";
|
||||
import MercuryDataSource from "./index.js";
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { DataSource } from "typeorm";
|
||||
import * as config from "../config.js";
|
||||
import * as config from "~/config.js";
|
||||
|
||||
// Entity types
|
||||
import { Account } from "./entities/account.js";
|
||||
import { Blog } from "./entities/blog.js";
|
||||
import { Post } from "./entities/post.js";
|
||||
import { Account } from "~entities/account.js";
|
||||
import { Blog } from "~entities/blog.js";
|
||||
import { Post } from "~entities/post.js";
|
||||
|
||||
const MercuryDataSource = new DataSource({
|
||||
type: "postgres",
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import type { FastifyReply, FastifyRequest, RouteOptions } from "fastify";
|
||||
import { IsNull } from "typeorm";
|
||||
|
||||
import log from "../../log.js";
|
||||
import MercuryDataSource from "../../db/index.js";
|
||||
import { Blog } from "../../db/entities/blog.js";
|
||||
import { BASE_URL } from "../../config.js";
|
||||
import log from "~/log.js";
|
||||
import MercuryDataSource from "~/db/index.js";
|
||||
import { Blog } from "~entities/blog.js";
|
||||
import { BASE_URL } from "~/config.js";
|
||||
|
||||
const route: RouteOptions = {
|
||||
method: "GET",
|
||||
|
|
|
@ -16,5 +16,10 @@
|
|||
"strict": true,
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": false,
|
||||
"baseUrl": "./",
|
||||
"paths": {
|
||||
"~/*": ["./src/*"],
|
||||
"~entities/*": ["./src/db/entities/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue