Skip to content

Commit

Permalink
Revert "Initial update"
Browse files Browse the repository at this point in the history
This reverts commit f690559.
  • Loading branch information
inetol committed Aug 26, 2024
1 parent 7d5a989 commit 5e81dc9
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 122 deletions.
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# JSPaste specific
storage/

# Databases
*.db
*.sql
*.sqlite
*.sqlite3
# JSP specific
documents/

# Logs
logs
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ LABEL org.opencontainers.image.url="https://jspaste.eu" \
org.opencontainers.image.documentation="https://docs.jspaste.eu" \
org.opencontainers.image.licenses="EUPL-1.2"

VOLUME /backend/storage/
VOLUME /backend/documents/
EXPOSE 4000

ENTRYPOINT ["./backend"]
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"files": {
"ignore": ["dist/**", "storage/**", "*.spec.ts"],
"ignore": ["dist/**", "documents/**", "*.spec.ts"],
"ignoreUnknown": true
},
"formatter": {
Expand Down
Binary file modified bun.lockb
Binary file not shown.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@
"start:dev": "bun run src/index.ts"
},
"dependencies": {
"@hono/zod-openapi": "~0.16.0",
"@scalar/hono-api-reference": "~0.5.143",
"@hono/zod-openapi": "~0.15.1",
"@scalar/hono-api-reference": "~0.5.128",
"@swc/cli": "~0.4.0",
"@swc/core": "~1.7.18",
"@types/bun": "~1.1.8",
"@swc/core": "~1.7.5",
"@types/bun": "~1.1.6",
"cbor-x": "~1.6.0",
"chalk": "~5.3.0",
"env-var": "~7.5.0",
"hono": "~4.5.9",
"hono": "~4.5.3",
"loglevel": "~1.9.1",
"typescript": "~5.5.4"
},
"devDependencies": {
"@biomejs/biome": "~1.8.3",
"lefthook": "~1.7.14",
"sort-package-json": "~2.10.1"
"lefthook": "~1.7.11",
"sort-package-json": "~2.10.0"
},
"trustedDependencies": [
"@biomejs/biome",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { logger } from './logger.ts';
import { env, server } from './server.ts';

logger.set(env.logLevel);
// TODO: Support graceful shutdown
process.on('SIGTERM', () => process.exit(0));

export default {
port: env.port,
Expand Down
15 changes: 4 additions & 11 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { get as envvar } from 'env-var';
import { cors } from 'hono/cors';
import { HTTPException } from 'hono/http-exception';
import { logger } from './logger.ts';
import { database } from './server/database.ts';
import { documentation } from './server/documentation.ts';
import { endpoints } from './server/endpoints.ts';
import { errorHandler } from './server/errorHandler.ts';
Expand All @@ -15,24 +14,23 @@ export const env = {
tls: envvar('TLS').asBoolStrict() ?? true,
documentMaxSize: envvar('DOCUMENT_MAXSIZE').default(1024).asIntPositive(),
docsEnabled: envvar('DOCS_ENABLED').asBoolStrict() ?? false,
debugDB: envvar('DEBUG_DB').asBoolStrict() ?? false,
docsPath: envvar('DOCS_PATH').default('/docs').asString()
} as const;

export const config = {
protocol: env.tls ? 'https://' : 'http://',
apiPath: '/api',
storagePath: 'storage/',
storagePath: 'documents/',
documentNameLengthMin: 2,
documentNameLengthMax: 32,
documentNameLengthDefault: 8
} as const;

export const db = database.open();

const instance = new OpenAPIHono().basePath(config.apiPath);

export const server = (): typeof instance => {
logger.set(env.logLevel);

instance.use('*', cors());

instance.onError((err) => {
Expand All @@ -51,14 +49,9 @@ export const server = (): typeof instance => {
endpoints(instance);
env.docsEnabled && documentation(instance);

logger.debug('Registered', instance.routes.length, 'routes');
logger.debug('Registered routes:', instance.routes);
logger.info(`Listening on: http://localhost:${env.port}`);

return instance;
};

// TODO: Support graceful shutdown
process.on('SIGTERM', () => {
db.close(false);
process.exit(0);
});
80 changes: 0 additions & 80 deletions src/server/database.ts

This file was deleted.

16 changes: 4 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"noEmit": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,

"strict": true,
"allowUnreachableCode": false,
Expand All @@ -23,20 +24,11 @@
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noPropertyAccessFromIndexSignature": false,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"verbatimModuleSyntax": true,

"baseUrl": ".",
"paths": {
"@x-v1/*": ["./src/endpoints/v1/*"],
"@x-v2/*": ["./src/endpoints/v2/*"],
"@x-document/*": ["./src/document/*"],
"@x-server/*": ["./src/server/*"],
"@x-util/*": ["./src/utils/*"]
}
"verbatimModuleSyntax": true
},
"exclude": ["dist/**", "storage/**"]
"exclude": ["dist/**", "documents/**"]
}

0 comments on commit 5e81dc9

Please sign in to comment.