Skip to content

Commit 9388983

Browse files
committed
feat(template): update source as @boringcodes/utils updated, replace ts type with interface & pretifier some files
1 parent d092cec commit 9388983

File tree

6 files changed

+24
-28
lines changed

6 files changed

+24
-28
lines changed

generators/app/templates/src/app.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import express from 'express';
22
import morgan from 'morgan';
33
import bodyParser from 'body-parser';
4-
import { isDev } from '@boringcodes/utils/dist';
5-
import { health, handleNotFound, handleErrors } from '@boringcodes/utils/dist/express';
4+
import { isDev } from '@boringcodes/utils';
5+
import { health, handleNotFound, handleErrors } from '@boringcodes/utils/express';
66

77
import routes from './routes';
88

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
const NAME = 'thing';
22
const PLURAL_NAME = 'things';
33

4-
export {
5-
NAME,
6-
PLURAL_NAME,
7-
};
4+
export { NAME, PLURAL_NAME };

generators/app/templates/src/components/things/controller.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { Request as ExpressRequest, Response, NextFunction } from 'express';
2-
import { BAD_REQUEST, NOT_FOUND, INTERNAL_SERVER_ERROR } from 'http-status-codes';
3-
import { HttpError } from '@boringcodes/utils/dist/error';
2+
import {
3+
BAD_REQUEST,
4+
NOT_FOUND,
5+
INTERNAL_SERVER_ERROR,
6+
} from 'http-status-codes';
7+
import { HttpError } from '@boringcodes/utils/error';
48

59
import { NAME } from './constants';
610

7-
type Request = ExpressRequest & {
8-
readonly [NAME]: any,
11+
interface Request extends ExpressRequest {
12+
readonly [NAME]: any;
913
};
1014

1115
const list = async (_: Request, res: Response, next: NextFunction) => {
@@ -92,12 +96,4 @@ const del = async (req: Request, res: Response, next: NextFunction) => {
9296
}
9397
};
9498

95-
export {
96-
list,
97-
create,
98-
count,
99-
getById,
100-
get,
101-
update,
102-
del,
103-
};
99+
export { list, create, count, getById, get, update, del };

generators/app/templates/src/components/things/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Router } from 'express';
22

3+
import { Routes } from '../types';
34
import { PLURAL_NAME } from './constants';
45
import { list, count, create, getById, get, update, del } from './controller';
5-
import { Routes } from '../types';
66

77
const path = `/${PLURAL_NAME}`;
88

@@ -11,14 +11,17 @@ const routes = (_: Routes) => {
1111

1212
router.param('id', getById);
1313

14-
router.route('/')
14+
router
15+
.route('/')
1516
.get(list)
1617
.post(create);
1718

18-
router.route('/count')
19+
router
20+
.route('/count')
1921
.get(count);
2022

21-
router.route('/:id')
23+
router
24+
.route('/:id')
2225
.get(get)
2326
.put(update)
2427
.delete(del);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
type Routes = {
2-
readonly dev: boolean,
3-
};
1+
interface Routes {
2+
readonly dev: boolean;
3+
}
44

55
export { Routes };

generators/app/templates/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import errorHandler from '@boringcodes/utils/dist/errorHandler';
2-
import logger from '@boringcodes/utils/dist/logger';
1+
import errorHandler from '@boringcodes/utils/errorHandler';
2+
import logger from '@boringcodes/utils/logger';
33

44
import app from './app';
55

0 commit comments

Comments
 (0)