mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-13 01:53:57 +00:00
69 lines
1.1 KiB
TypeScript
69 lines
1.1 KiB
TypeScript
|
/**
|
||
|
* Required External Modules
|
||
|
*/
|
||
|
|
||
|
import * as dotenv from "dotenv";
|
||
|
import express from "express";
|
||
|
import cors from "cors";
|
||
|
import helmet from "helmet";
|
||
|
|
||
|
dotenv.config();
|
||
|
|
||
|
|
||
|
/**
|
||
|
* App Variables
|
||
|
*/
|
||
|
|
||
|
if (!process.env.PORT) {
|
||
|
process.exit(1);
|
||
|
}
|
||
|
|
||
|
const PORT: number = parseInt(process.env.PORT as string, 10);
|
||
|
|
||
|
const app = express();
|
||
|
|
||
|
|
||
|
/**
|
||
|
* App Configuration
|
||
|
*/
|
||
|
|
||
|
app.use(helmet());
|
||
|
app.use(cors());
|
||
|
app.use(express.json());
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Server Activation
|
||
|
*/
|
||
|
|
||
|
const server = app.listen(PORT, () => {
|
||
|
console.log(`Listening on port ${PORT}`);
|
||
|
});
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Webpack HMR Activation
|
||
|
*/
|
||
|
|
||
|
type ModuleId = string | number;
|
||
|
|
||
|
interface WebpackHotModule {
|
||
|
hot?: {
|
||
|
data: any;
|
||
|
accept(
|
||
|
dependencies: string[],
|
||
|
callback?: (updatedDependencies: ModuleId[]) => void,
|
||
|
): void;
|
||
|
accept(dependency: string, callback?: () => void): void;
|
||
|
accept(errHandler?: (err: Error) => void): void;
|
||
|
dispose(callback: (data: any) => void): void;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
declare const module: WebpackHotModule;
|
||
|
|
||
|
if (module.hot) {
|
||
|
module.hot.accept();
|
||
|
module.hot.dispose(() => server.close());
|
||
|
}
|