Fix more stuff.
This commit is contained in:
parent
6cbbb1bf1f
commit
886d0e8df2
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
node_modules/
|
||||
proto/
|
||||
!proto_src/proto/
|
||||
!src/proto/
|
||||
!src/proto/proto/
|
||||
.env
|
||||
dist/
|
||||
server_wangan.key
|
@ -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",
|
||||
|
13
src/index.ts
13
src/index.ts
@ -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
5
src/module.ts
Normal 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
8
src/modules/startup.ts
Normal 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!');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user