Skip to content

Commit

Permalink
Merge branch 'develop' into feature/#11-routes
Browse files Browse the repository at this point in the history
  • Loading branch information
beevk committed Mar 16, 2022
2 parents f7d25ce + a06c42e commit 2cebfb6
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 24 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ts-express-postgresql",
"version": "1.0.0",
"description": "Just another Boilerplate for TS, Express & PostgreSQL",
"main": "source/server.ts",
"main": "src/server.ts",
"lint-staged": {
"*.{js,ts}": [
"eslint --fix"
Expand All @@ -15,7 +15,7 @@
}
},
"scripts": {
"dev": "nodemon source/server.ts",
"dev": "nodemon src/server.ts",
"start": "node build/server.js",
"build": "rm -rf build/ && tsc",
"clean": "rm -rf build",
Expand Down
11 changes: 0 additions & 11 deletions source/app.ts

This file was deleted.

11 changes: 11 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import express, { Express } from 'express';
import 'reflect-metadata';
import ConfigureApp from './bootstrap';

export default async (): Promise<Express> => {
const app = express();

await ConfigureApp(app);

return app;
};
9 changes: 6 additions & 3 deletions source/bootstrap/index.ts → src/bootstrap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import express, { Express, NextFunction, Request, Response } from 'express';
import helmet from 'helmet';
import cors from 'cors';

import morganMiddleware from '../utils/logging';
import morganMiddleware, { logError } from '../utils/logging';
import router from '../routes';

export const ConfigureApp = (app: Express) => {
const ConfigureApp = (app: Express): void => {
if (!app) {
return;
}
Expand All @@ -28,11 +28,14 @@ export const ConfigureApp = (app: Express) => {
app.use('/', router);

/** Global catch block - 500 */
const ErrorHandler = (err: Error, req: Request, res: Response, next: NextFunction) => {
const ErrorHandler = (err: Error, req: Request, res: Response, _: NextFunction) => {
logError(err.message);
return res.status(500).json({
message: err.message
});
};
app.use(ErrorHandler);
// Don't add any middleware below this
};

export default ConfigureApp;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Service } from 'typedi';

@Service()
export default class SampleInjectedService {
printMessage() {
printMessage(): void {
console.log('Ping from SampleInjectedService!');
}
}
6 changes: 3 additions & 3 deletions source/utils/logging.ts → src/utils/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ const morganMiddleware = morgan((tokens, req, res) => {
].join(' ');
});

export const logInfo = (message: string): any => console.info(chalk.hex('#34ACE0').bold(message));
export const logWarning = (message: string): any => console.warn(chalk.hex('#ff9966').bold(message));
export const logError = (message: string): any => console.error(chalk.hex('#ff5252').bold(message));
export const logInfo = (message: string): void => console.info(chalk.hex('#34ACE0').bold(message));
export const logWarning = (message: string): void => console.warn(chalk.hex('#ff9966').bold(message));
export const logError = (message: string): void => console.error(chalk.hex('#ff5252').bold(message));

export default morganMiddleware;
8 changes: 4 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each src file. */

/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
Expand All @@ -53,10 +53,10 @@
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of src locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
// "inlineSourceMap": true, /* Emit a single file with src maps instead of having a separate file. */
// "inlineSources": true, /* Emit the src alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
Expand Down

0 comments on commit 2cebfb6

Please sign in to comment.