1
0
mirror of synced 2024-12-04 19:17:58 +01:00

Fix more stuff.

This commit is contained in:
Rin 2022-07-11 09:15:30 +01:00
parent 6cbbb1bf1f
commit 886d0e8df2
10 changed files with 31 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,6 +1,7 @@
node_modules/
proto/
!proto_src/proto/
!src/proto/
!src/proto/proto/
.env
dist/
server_wangan.key

View File

@ -7,6 +7,9 @@
"author": "Luna and Project Asakura",
"license": "MIT",
"private": false,
"scripts": {
"dev": "tsc && node dist"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^18.0.3",

View File

@ -8,6 +8,19 @@ import fs from 'fs';
const app = express();
let dirs = fs.readdirSync('dist/modules');
for (let i of dirs) {
if (i.endsWith('.js')) {
let mod = require(`./modules/${i.substring(0, i.length - 3)}`); // .js extension
let inst = new mod.default();
inst.register(app);
}
}
app.all('*', (req, res) => {
console.log(`CATCH-ALL: ${req.method} ${req.originalUrl}`);
})
https.createServer({
key: fs.readFileSync('server_wangan.key'),
cert: fs.readFileSync('server_wangan.crt')

5
src/module.ts Normal file
View File

@ -0,0 +1,5 @@
import {Application} from 'express';
export abstract class Module {
abstract register(app: Application): void;
}

8
src/modules/startup.ts Normal file
View File

@ -0,0 +1,8 @@
import { Application } from "express";
import {Module} from "module";
export default class StartupModule extends Module {
register(app: Application): void {
console.log('test!');
}
}