Skip to content

Commit 3865561

Browse files
committed
Refactor customer console
1 parent ad333f9 commit 3865561

File tree

7 files changed

+25
-29
lines changed

7 files changed

+25
-29
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 아구몬
3+
Copyright (c) 2020 아구몬
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

typescript-express-starter/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 아구몬
3+
Copyright (c) 2020 아구몬
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

typescript-express-starter/lib/default/src/middlewares/error.middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Request, Response } from 'express';
1+
import { Request, Response, NextFunction } from 'express';
22
import HttpException from '../exceptions/HttpException';
33

4-
function errorMiddleware(error: HttpException, req: Request, res: Response) {
4+
function errorMiddleware(error: HttpException, req: Request, res: Response, next: NextFunction) {
55
const status: number = error.status || 500;
66
const message: string = error.message || 'Something went wrong';
77

8-
console.log('[ERROR] ', status, message);
8+
console.error('[ERROR] ', status, message);
99

1010
res.status(status).json({ message });
1111
}

typescript-express-starter/lib/mongoose/src/app.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,13 @@ class App {
5959
}
6060

6161
private connectToDatabase() {
62-
const { MONGO_USER, MONGO_PASSWORD, MONGO_PATH } = process.env;
63-
const options = {
64-
useCreateIndex: true,
65-
useNewUrlParser: true,
66-
useUnifiedTopology: true,
67-
useFindAndModify: false,
68-
};
62+
const {
63+
MONGO_USER,
64+
MONGO_PASSWORD,
65+
MONGO_PATH
66+
} = process.env;
6967

70-
if (this.env) {
71-
// production database
72-
} else {
73-
mongoose.connect(`mongodb://${MONGO_USER}:${MONGO_PASSWORD}${MONGO_PATH}?authSource=admin`, { ...options });
74-
}
68+
mongoose.connect(`mongodb://${MONGO_USER}:${MONGO_PASSWORD}${MONGO_PATH}`);
7569
}
7670
}
7771

typescript-express-starter/lib/mongoose/src/middlewares/error.middleware.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Request, Response } from 'express';
1+
import { Request, Response, NextFunction } from 'express';
22
import HttpException from '../exceptions/HttpException';
33

4-
function errorMiddleware(error: HttpException, req: Request, res: Response) {
4+
function errorMiddleware(error: HttpException, req: Request, res: Response, next: NextFunction) {
55
const status: number = error.status || 500;
66
const message: string = error.message || 'Something went wrong';
77

8-
console.log('[ERROR] ', status, message);
8+
console.error('[ERROR] ', status, message);
99

1010
res.status(status).json({ message });
1111
}

typescript-express-starter/lib/typescript-express-starter.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@
55

66
const path = require('path');
77
const fs = require('fs');
8-
const log = require('signale');
98
const editJsonFile = require('edit-json-file');
109
const childProcess = require('child_process');
11-
const inquirer = require('inquirer');
1210
const ncp = require('ncp').ncp;
11+
const inquirer = require('inquirer');
12+
const chalk = require('chalk');
13+
const ora = require('ora');
1314

1415
async function tsExpressStarter(destination) {
1516
try {
1617
const directory = await fetchDirectory();
18+
const spinner = ora(`Setting up new TypeScript Express Starter Project`).start();
1719
await copyProjectFiles(destination, directory);
1820
updatePackageJson(destination);
1921
const dep = getDepStrings(directory);
2022
downloadNodeModules(destination, dep);
21-
log.success('Project setup complete!');
22-
} catch (err) {
23-
log.error(err);
23+
spinner.succeed(`${chalk.green('Project setup complete!')}`);
24+
} catch (error) {
25+
console.error(`${chalk.red('[ERROR] Please leave this error as an issue.')}\n${error}`);
2426
}
2527
};
2628

@@ -36,7 +38,6 @@ async function fetchDirectory() {
3638
}
3739
]);
3840

39-
log.start('Setting up new TypeScript-Express-Starter Project');
4041
return selectedTemplates;
4142
};
4243

typescript-express-starter/package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
"typescript-express-starter": "bin/cli.js"
2222
},
2323
"dependencies": {
24+
"chalk": "^3.0.0",
2425
"edit-json-file": "^1.3.2",
25-
"inquirer": "^6.2.2",
26+
"inquirer": "^6.5.2",
2627
"ncp": "^2.0.0",
27-
"recursive-readdir": "^2.2.2",
28-
"signale": "^1.4.0"
28+
"ora": "^4.0.3",
29+
"recursive-readdir": "^2.2.2"
2930
},
3031
"repository": {
3132
"type": "git",

0 commit comments

Comments
 (0)