Skip to content

Commit

Permalink
feat(routes): serve index file to get request
Browse files Browse the repository at this point in the history
  • Loading branch information
tks18 committed Dec 25, 2021
1 parent 52a2b4c commit 2f2dddb
Show file tree
Hide file tree
Showing 5 changed files with 645 additions and 41 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
tests
dist
out
webpack.config.js
.eslintrc.js
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"chai-each": "^0.0.1",
"chai-http": "^4.3.0",
"commitizen": "^4.2.4",
"copy-webpack-plugin": "^10.2.0",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.32.0",
"eslint-config-google": "^0.14.0",
Expand All @@ -97,6 +98,7 @@
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.1",
"husky": "^7.0.4",
"javascript-obfuscator": "^3.0.0",
"jsdoc": "^3.6.7",
"mocha": "^9.1.3",
"mocha-simple-html-reporter": "^2.0.0",
Expand All @@ -110,7 +112,8 @@
"typescript": "^4.5.2",
"webpack": "^5.64.4",
"webpack-cli": "^4.9.1",
"webpack-node-externals": "^3.0.0"
"webpack-node-externals": "^3.0.0",
"webpack-obfuscator": "^3.5.0"
},
"config": {
"commitizen": {
Expand Down
8 changes: 4 additions & 4 deletions routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import express from 'express';
import { checkSecretPass } from '@plugins/server/middlewares';
import setupCheck from '@plugins/server/middlewares/first-setup';

// Response Handlers
import { okResponse } from '@plugins/server/responses';
// Others
import path from 'path';

// Routes
import firstSetup from './first-setup';
Expand All @@ -21,8 +21,8 @@ router.use('/setup', [setupCheck, checkSecretPass], firstSetup);
router.use('/login', login);

// Default Get
router.get('/', (req, res) => {
okResponse<string>(res, 'Server Successfully Started');
router.get(/(\/.*)+/, (req, res) => {
res.status(200).sendFile(path.resolve(__dirname, '../views/index.html'));
});

// Respond with all the Endpoints in this Route
Expand Down
19 changes: 19 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const nodeExternals = require('webpack-node-externals');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const WebpackObfuscator = require('webpack-obfuscator');
const path = require('path');

module.exports = {
Expand All @@ -22,6 +24,23 @@ module.exports = {
},
],
},
plugins: [
new WebpackObfuscator(
{
compact: true,
target: 'node',
},
['views/**'],
),
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'views'),
to: path.resolve(__dirname, 'out', 'views'),
},
],
}),
],
resolve: {
extensions: ['.ts', '.tsx', '.js'],
plugins: [new TsconfigPathsPlugin()],
Expand Down
Loading

0 comments on commit 2f2dddb

Please sign in to comment.