Inital commit
This commit is contained in:
commit
917effe259
30 files changed
+22019
No files matched your search
@@ -0,0 +1,33 @@
|
||||
import { Encryptor } from "./encryptor";
|
||||
import { readFileSync } from "fs";
|
||||
import * as path from "path";
|
||||
import express from "express";
|
||||
import { api } from "./api";
|
||||
|
||||
const config = JSON.parse(readFileSync(path.join(process.cwd(), "config.json"), "utf8")) as {
|
||||
PORT: number;
|
||||
VALIDATOR_STRING: string;
|
||||
};
|
||||
|
||||
Encryptor.setMagic(config.VALIDATOR_STRING);
|
||||
|
||||
const app = express();
|
||||
|
||||
app.disable('x-powered-by');
|
||||
app.use(express.static("build"));
|
||||
app.use((req, res, next) => {
|
||||
res.header('Access-Control-Allow-Origin', '*');
|
||||
res.header('Access-Control-Allow-Methods', 'GET,POST,PUT,DELETE,OPTIONS');
|
||||
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||
if (req.method === 'OPTIONS') {
|
||||
return res.sendStatus(204); // Respond to preflight requests
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
app.use("/api", api);
|
||||
|
||||
app.listen(config.PORT, () => {
|
||||
console.log(`Listening to ${config.PORT}`);
|
||||
});
|
||||
Reference in new issue
Block a user