express-generator-typescript 2.7.6 → 2.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-git +2 -3
- package/README.md +1 -1
- package/lib/express-generator-typescript.js +1 -1
- package/package.json +18 -20
- package/lib/project-files/README.md +0 -65
- package/lib/project-files/config/.env.development +0 -15
- package/lib/project-files/config/.env.production +0 -15
- package/lib/project-files/config/.env.test +0 -14
- package/lib/project-files/config.ts +0 -22
- package/lib/project-files/eslint.config.ts +0 -100
- package/lib/project-files/gitignore +0 -6
- package/lib/project-files/package.json +0 -57
- package/lib/project-files/scripts/build.ts +0 -28
- package/lib/project-files/scripts/common/utils.ts +0 -93
- package/lib/project-files/src/common/constants/ENV.ts +0 -19
- package/lib/project-files/src/common/constants/HTTP_STATUS_CODES.ts +0 -81
- package/lib/project-files/src/common/constants/PATHS.ts +0 -15
- package/lib/project-files/src/common/constants/index.ts +0 -11
- package/lib/project-files/src/common/util/misc.ts +0 -11
- package/lib/project-files/src/common/util/route-errors.ts +0 -38
- package/lib/project-files/src/common/util/validators.ts +0 -21
- package/lib/project-files/src/index.ts +0 -27
- package/lib/project-files/src/models/User.ts +0 -69
- package/lib/project-files/src/models/common/types/index.ts +0 -5
- package/lib/project-files/src/public/scripts/http.js +0 -26
- package/lib/project-files/src/public/scripts/users.js +0 -141
- package/lib/project-files/src/public/stylesheets/users.css +0 -48
- package/lib/project-files/src/repos/MockOrm.ts +0 -63
- package/lib/project-files/src/repos/UserRepo.ts +0 -134
- package/lib/project-files/src/repos/database.json +0 -1
- package/lib/project-files/src/repos/database.test.json +0 -1
- package/lib/project-files/src/routes/UserRoutes.ts +0 -69
- package/lib/project-files/src/routes/common/types/index.ts +0 -10
- package/lib/project-files/src/routes/common/util/index.ts +0 -16
- package/lib/project-files/src/routes/index.ts +0 -31
- package/lib/project-files/src/server.ts +0 -86
- package/lib/project-files/src/services/UserService.ts +0 -70
- package/lib/project-files/src/views/users.html +0 -132
- package/lib/project-files/tests/common/types/index.ts +0 -16
- package/lib/project-files/tests/common/util/index.ts +0 -55
- package/lib/project-files/tests/support/setup.ts +0 -26
- package/lib/project-files/tests/users.test.ts +0 -138
- package/lib/project-files/tsconfig.json +0 -35
- package/lib/project-files/tsconfig.prod.json +0 -30
- package/lib/project-files/vitest.config.mts +0 -18
package/README-git
CHANGED
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
|
|
11
11
|
# express-generator-typescript
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Command line tool which generates production-ready express templates with TypeScript baked in. Spin up a web server in seconds that follows the [TypeScript best practices](https://github.com/seanpmaxwell/Typescript-Best-Practices/blob/main/README.md).
|
|
14
14
|
|
|
15
15
|
## Overview
|
|
16
16
|
|
|
17
|
-
`express-generator-typescript` creates a new Express application similar to the classic `express-generator` package, but the generated project is fully wired for TypeScript
|
|
17
|
+
`express-generator-typescript` creates a new Express application similar to the classic `express-generator` package, but the generated project is fully wired for TypeScript. You get strict typing, linting, hot reloading, production builds, testing utilities, and sane defaults that focus on APIs (no view engine or opinionated ORM). Path aliases are preconfigured through `tsconfig-paths` and `_moduleAliases`, so referencing modules stays clean even as the app grows.
|
|
18
18
|
|
|
19
19
|
## Features
|
|
20
20
|
|
|
@@ -52,7 +52,6 @@ Use `--use-yarn` if you prefer Yarn over npm. If you omit the project name, the
|
|
|
52
52
|
| ----------------- | --------------------------------------------------------------------------- |
|
|
53
53
|
| `project name` | Folder to create. Defaults to `express-gen-ts` if omitted. |
|
|
54
54
|
| `--use-yarn` | Installs dependencies with Yarn instead of npm. |
|
|
55
|
-
| `--version` | Prints the generator version. |
|
|
56
55
|
|
|
57
56
|
> The historical `--with-auth` switch was removed in v2.5+. For an auth-ready example see the [express-jsonwebtoken-demo](https://github.com/seanpmaxwell/express-jsonwebtoken-demo) project.
|
|
58
57
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
# express-generator-typescript
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Command line tool which generates production-ready express templates with TypeScript baked in. Spin up a web server in seconds that follows the [TypeScript best practices](https://github.com/seanpmaxwell/Typescript-Best-Practices/blob/main/README.md).
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
## Documenation
|
|
@@ -14,7 +14,7 @@ const PROJECT_FOLDER_PATH = './project-files';
|
|
|
14
14
|
|
|
15
15
|
// Project-folder dependencies
|
|
16
16
|
const DEPENDENCIES = 'express dotenv morgan cookie-parser jet-logger ' +
|
|
17
|
-
'module-alias helmet jsonfile
|
|
17
|
+
'module-alias helmet jsonfile jet-paths dayjs jet-env ' +
|
|
18
18
|
'jet-validators',
|
|
19
19
|
DEV_DEPENDENCIES = 'ts-node typescript nodemon find supertest vitest ' +
|
|
20
20
|
'@types/node @types/find @types/morgan @types/cookie-parser ' +
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.8",
|
|
4
4
|
"description": "Generate new Express applications similar to express-generate which but sets it up to use TypeScript instead",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"express-generator-typescript": "node bin/cli.js",
|
|
@@ -19,27 +19,25 @@
|
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"express",
|
|
22
|
-
"
|
|
23
|
-
"generator",
|
|
24
|
-
"generate",
|
|
25
|
-
"gen",
|
|
22
|
+
"express-generator",
|
|
23
|
+
"express-generator-typescript",
|
|
26
24
|
"typescript",
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
25
|
+
"typescript-express",
|
|
26
|
+
"api",
|
|
27
|
+
"rest",
|
|
28
|
+
"rest-api",
|
|
29
|
+
"scaffold",
|
|
30
|
+
"scaffolding",
|
|
31
|
+
"cli",
|
|
32
|
+
"generator",
|
|
33
|
+
"nodejs",
|
|
34
|
+
"backend",
|
|
35
|
+
"boilerplate",
|
|
36
|
+
"starter",
|
|
37
|
+
"template",
|
|
35
38
|
"express-ts",
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"test",
|
|
39
|
-
"testing",
|
|
40
|
-
"routes",
|
|
41
|
-
"router",
|
|
42
|
-
"routing"
|
|
39
|
+
"server",
|
|
40
|
+
"tooling"
|
|
43
41
|
],
|
|
44
42
|
"author": "sean maxwell",
|
|
45
43
|
"license": "MIT",
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
## About
|
|
2
|
-
|
|
3
|
-
This project was created with [express-generator-typescript](https://github.com/seanpmaxwell/express-generator-typescript).
|
|
4
|
-
|
|
5
|
-
**IMPORTANT** for demo purposes I had to disable `helmet` in production. In any real world app you should change these 3 lines of code in `src/server.ts`:
|
|
6
|
-
```ts
|
|
7
|
-
// eslint-disable-next-line n/no-process-env
|
|
8
|
-
if (!process.env.DISABLE_HELMET) {
|
|
9
|
-
app.use(helmet());
|
|
10
|
-
}
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
To just this:
|
|
14
|
-
```ts
|
|
15
|
-
app.use(helmet());
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
## Available Scripts
|
|
20
|
-
|
|
21
|
-
### `npm run clean-install`
|
|
22
|
-
|
|
23
|
-
Remove the existing `node_modules/` folder, `package-lock.json`, and reinstall all library modules.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### `npm run dev` or `npm run dev:hot` (hot reloading)
|
|
27
|
-
|
|
28
|
-
Run the server in development mode.<br/>
|
|
29
|
-
|
|
30
|
-
**IMPORTANT** development mode uses `swc` for performance reasons which DOES NOT check for typescript errors. Run `npm run type-check` to check for type errors. NOTE: you should use your IDE to prevent most type errors.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### `npm test` or `npm run test:hot` (hot reloading)
|
|
34
|
-
|
|
35
|
-
Run all unit-tests.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### `npm test -- "name of test file" (i.e. users).`
|
|
39
|
-
|
|
40
|
-
Run a single unit-test.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### `npm run lint`
|
|
44
|
-
|
|
45
|
-
Check for linting errors.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### `npm run build`
|
|
49
|
-
|
|
50
|
-
Build the project for production.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### `npm start`
|
|
54
|
-
|
|
55
|
-
Run the production build (Must be built first).
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
### `npm run type-check`
|
|
59
|
-
|
|
60
|
-
Check for typescript errors.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
## Additional Notes
|
|
64
|
-
|
|
65
|
-
- If `npm run dev` gives you issues with bcrypt on MacOS you may need to run: `npm rebuild bcrypt --build-from-source`.
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
## Environment ##
|
|
2
|
-
NODE_ENV=production
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
## Server ##
|
|
6
|
-
PORT=8081
|
|
7
|
-
HOST=localhost
|
|
8
|
-
DISABLE_HELMET=TRUE
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Setup jet-logger ##
|
|
12
|
-
JET_LOGGER_MODE=FILE
|
|
13
|
-
JET_LOGGER_FILEPATH=jet-logger.log
|
|
14
|
-
JET_LOGGER_TIMESTAMP=TRUE
|
|
15
|
-
JET_LOGGER_FORMAT=LINE
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/* eslint-disable n/no-process-env */
|
|
2
|
-
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import dotenv from 'dotenv';
|
|
5
|
-
import moduleAlias from 'module-alias';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Check the env
|
|
9
|
-
const NODE_ENV = (process.env.NODE_ENV ?? 'development');
|
|
10
|
-
|
|
11
|
-
// Configure "dotenv"
|
|
12
|
-
const result2 = dotenv.config({
|
|
13
|
-
path: path.join(__dirname, `./config/.env.${NODE_ENV}`),
|
|
14
|
-
});
|
|
15
|
-
if (result2.error) {
|
|
16
|
-
throw result2.error;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Configure moduleAlias
|
|
20
|
-
if (__filename.endsWith('js')) {
|
|
21
|
-
moduleAlias.addAlias('@src', __dirname + '/dist');
|
|
22
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import eslint from '@eslint/js';
|
|
2
|
-
import tseslint from 'typescript-eslint';
|
|
3
|
-
import stylistic from '@stylistic/eslint-plugin';
|
|
4
|
-
import nodePlugin from 'eslint-plugin-n';
|
|
5
|
-
import { defineConfig } from 'eslint/config';
|
|
6
|
-
|
|
7
|
-
export default defineConfig(
|
|
8
|
-
eslint.configs.recommended,
|
|
9
|
-
nodePlugin.configs['flat/recommended-script'],
|
|
10
|
-
...tseslint.configs.strictTypeChecked,
|
|
11
|
-
...tseslint.configs.stylisticTypeChecked,
|
|
12
|
-
{
|
|
13
|
-
ignores: [
|
|
14
|
-
'**/node_modules/*',
|
|
15
|
-
'**/*.mjs',
|
|
16
|
-
'**/*.js',
|
|
17
|
-
],
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
languageOptions: {
|
|
21
|
-
parserOptions: {
|
|
22
|
-
project: './tsconfig.json',
|
|
23
|
-
warnOnUnsupportedTypeScriptVersion: false,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
plugins: {
|
|
29
|
-
'@stylistic': stylistic,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
files: ['**/*.ts'],
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
rules: {
|
|
37
|
-
'@typescript-eslint/explicit-member-accessibility': 'warn',
|
|
38
|
-
'@typescript-eslint/no-misused-promises': 0,
|
|
39
|
-
'@typescript-eslint/no-floating-promises': 0,
|
|
40
|
-
'@typescript-eslint/no-confusing-void-expression': 0,
|
|
41
|
-
'@typescript-eslint/no-unnecessary-condition': 0,
|
|
42
|
-
'@typescript-eslint/restrict-template-expressions': [
|
|
43
|
-
'error', { allowNumber: true },
|
|
44
|
-
],
|
|
45
|
-
'@typescript-eslint/restrict-plus-operands': [
|
|
46
|
-
'warn', { allowNumberAndString: true },
|
|
47
|
-
],
|
|
48
|
-
'@typescript-eslint/no-unused-vars': [
|
|
49
|
-
'warn',
|
|
50
|
-
{
|
|
51
|
-
argsIgnorePattern: '^_',
|
|
52
|
-
varsIgnorePattern: '^_',
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
'@typescript-eslint/no-unsafe-enum-comparison': 0,
|
|
56
|
-
'@typescript-eslint/no-unnecessary-type-parameters': 0,
|
|
57
|
-
'@stylistic/no-extra-semi': 'warn',
|
|
58
|
-
'max-len': [
|
|
59
|
-
'warn',
|
|
60
|
-
{
|
|
61
|
-
'code': 80,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
'@stylistic/semi': ['warn', 'always'],
|
|
65
|
-
'@stylistic/member-delimiter-style': ['warn', {
|
|
66
|
-
'multiline': {
|
|
67
|
-
'delimiter': 'comma',
|
|
68
|
-
'requireLast': true,
|
|
69
|
-
},
|
|
70
|
-
'singleline': {
|
|
71
|
-
'delimiter': 'comma',
|
|
72
|
-
'requireLast': false,
|
|
73
|
-
},
|
|
74
|
-
'overrides': {
|
|
75
|
-
'interface': {
|
|
76
|
-
'singleline': {
|
|
77
|
-
'delimiter': 'semi',
|
|
78
|
-
'requireLast': false,
|
|
79
|
-
},
|
|
80
|
-
'multiline': {
|
|
81
|
-
'delimiter': 'semi',
|
|
82
|
-
'requireLast': true,
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
}],
|
|
87
|
-
'@typescript-eslint/no-non-null-assertion': 0,
|
|
88
|
-
'@typescript-eslint/no-unused-expressions': 'warn',
|
|
89
|
-
'comma-dangle': ['warn', 'always-multiline'],
|
|
90
|
-
'no-console': 1,
|
|
91
|
-
'no-extra-boolean-cast': 0,
|
|
92
|
-
'indent': ['warn', 2],
|
|
93
|
-
'quotes': ['warn', 'single'],
|
|
94
|
-
'n/no-process-env': 1,
|
|
95
|
-
'n/no-missing-import': 0,
|
|
96
|
-
'n/no-unpublished-import': 0,
|
|
97
|
-
'prefer-const': 'warn',
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
);
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "express-typescript-example",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"scripts": {
|
|
5
|
-
"build": "ts-node ./scripts/build.ts",
|
|
6
|
-
"clean-install": "rm -rf ./node_modules && rm -r package-lock.json && npm i",
|
|
7
|
-
"dev": "NODE_ENV=development ts-node ./src",
|
|
8
|
-
"dev:hot": "nodemon --exec \"npm run dev\" --watch ./src --ext .ts",
|
|
9
|
-
"lint": "eslint .",
|
|
10
|
-
"start": "NODE_ENV=production node -r ./config.js ./dist",
|
|
11
|
-
"test": "NODE_ENV=test vitest",
|
|
12
|
-
"type-check": "tsc -b --noEmit"
|
|
13
|
-
},
|
|
14
|
-
"engines": {
|
|
15
|
-
"node": ">=16.0.0"
|
|
16
|
-
},
|
|
17
|
-
"dependencies": {
|
|
18
|
-
"cookie-parser": "^1.4.7",
|
|
19
|
-
"dayjs": "^1.11.13",
|
|
20
|
-
"dotenv": "^16.5.0",
|
|
21
|
-
"express": "^5.1.0",
|
|
22
|
-
"helmet": "^8.1.0",
|
|
23
|
-
"inserturlparams": "^2.0.5",
|
|
24
|
-
"jet-env": "^1.1.4",
|
|
25
|
-
"jet-logger": "^2.1.1",
|
|
26
|
-
"jet-paths": "^2.0.1",
|
|
27
|
-
"jet-validators": "^1.6.5",
|
|
28
|
-
"jsonfile": "^6.1.0",
|
|
29
|
-
"module-alias": "^2.2.3",
|
|
30
|
-
"morgan": "^1.10.0"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@eslint/js": "^9.25.1",
|
|
34
|
-
"@stylistic/eslint-plugin": "^5.5.0",
|
|
35
|
-
"@swc/core": "^1.11.22",
|
|
36
|
-
"@types/cookie-parser": "^1.4.8",
|
|
37
|
-
"@types/find": "^0.2.4",
|
|
38
|
-
"@types/fs-extra": "^11.0.4",
|
|
39
|
-
"@types/jsonfile": "^6.1.4",
|
|
40
|
-
"@types/module-alias": "^2.0.4",
|
|
41
|
-
"@types/morgan": "^1.9.9",
|
|
42
|
-
"@types/node": "^22.14.1",
|
|
43
|
-
"@types/supertest": "^6.0.3",
|
|
44
|
-
"eslint": "^9.25.1",
|
|
45
|
-
"eslint-plugin-n": "^17.17.0",
|
|
46
|
-
"find": "^0.3.0",
|
|
47
|
-
"fs-extra": "^11.3.0",
|
|
48
|
-
"jiti": "^2.4.2",
|
|
49
|
-
"nodemon": "^3.1.10",
|
|
50
|
-
"supertest": "^7.1.0",
|
|
51
|
-
"ts-node": "^10.9.2",
|
|
52
|
-
"tsconfig-paths": "^4.2.0",
|
|
53
|
-
"typescript": "^5.8.3",
|
|
54
|
-
"typescript-eslint": "^8.32.0",
|
|
55
|
-
"vitest": "^3.1.2"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import logger from 'jet-logger';
|
|
2
|
-
import { copy, copyFilesRec, exec, remove } from './common/utils';
|
|
3
|
-
|
|
4
|
-
/******************************************************************************
|
|
5
|
-
Run
|
|
6
|
-
******************************************************************************/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Start
|
|
10
|
-
*/
|
|
11
|
-
(async () => {
|
|
12
|
-
try {
|
|
13
|
-
// Remove current build
|
|
14
|
-
await remove('./dist/');
|
|
15
|
-
await exec('npm run lint', '../');
|
|
16
|
-
await exec('tsc --project tsconfig.prod.json', '../');
|
|
17
|
-
// Copy
|
|
18
|
-
await copyFilesRec('./src', './dist', ['.ts']);
|
|
19
|
-
await copy('./temp/config.js', './config.js');
|
|
20
|
-
await copy('./temp/src', './dist');
|
|
21
|
-
await remove('./temp/');
|
|
22
|
-
} catch (err) {
|
|
23
|
-
logger.err(err);
|
|
24
|
-
// eslint-disable-next-line n/no-process-exit
|
|
25
|
-
process.exit(1);
|
|
26
|
-
}
|
|
27
|
-
})();
|
|
28
|
-
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import logger from 'jet-logger';
|
|
3
|
-
import childProcess from 'child_process';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Functions
|
|
8
|
-
*******************************************************************************
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Copy file.
|
|
12
|
-
*/
|
|
13
|
-
export function copy(src: string, dest: string): Promise<void> {
|
|
14
|
-
return new Promise((res, rej) => {
|
|
15
|
-
return fs.copy(src, dest, err => {
|
|
16
|
-
return (!!err ? rej(err) : res());
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Remove file
|
|
23
|
-
*/
|
|
24
|
-
export function remove(loc: string): Promise<void> {
|
|
25
|
-
return new Promise((res, rej) => {
|
|
26
|
-
return fs.remove(loc, err => {
|
|
27
|
-
return (!!err ? rej(err) : res());
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Run command-line command.
|
|
34
|
-
*/
|
|
35
|
-
export function exec(cmd: string, loc = './'): Promise<string> {
|
|
36
|
-
// Setup directory
|
|
37
|
-
const callingDir = path.dirname(require.main?.filename ?? './'),
|
|
38
|
-
cwd = path.join(callingDir, loc);
|
|
39
|
-
// Wrap in promise
|
|
40
|
-
return new Promise((res, rej) =>
|
|
41
|
-
childProcess.exec(cmd, { cwd }, (err, stdout, stderr) => {
|
|
42
|
-
if (!!stdout) {
|
|
43
|
-
logger.info(stdout);
|
|
44
|
-
}
|
|
45
|
-
if (!!stderr) {
|
|
46
|
-
logger.err(stderr);
|
|
47
|
-
}
|
|
48
|
-
if (!!err) {
|
|
49
|
-
return rej(err);
|
|
50
|
-
} else if (!!stderr) {
|
|
51
|
-
return rej(new Error(stderr));
|
|
52
|
-
} else {
|
|
53
|
-
return res(stdout);
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Recursively search for a folder for all files and copy them to the new
|
|
61
|
-
* destination keeping their paths relative to the "src" param.
|
|
62
|
-
*
|
|
63
|
-
* Example:
|
|
64
|
-
* If file "./src/foo/bar.txt" exists then:
|
|
65
|
-
* copyFilesRec('./src', './dest') => ["./dest/foo/bar.txt"]
|
|
66
|
-
*
|
|
67
|
-
* @param excludeExt Exlude a list of file extensions.
|
|
68
|
-
*/
|
|
69
|
-
export async function copyFilesRec(
|
|
70
|
-
src: string,
|
|
71
|
-
dest: string,
|
|
72
|
-
excludeExt?: string[],
|
|
73
|
-
): Promise<void> {
|
|
74
|
-
const copyReqs: Promise<void>[] = [];
|
|
75
|
-
try {
|
|
76
|
-
const entries = await fs.readdir(src, { withFileTypes: true });
|
|
77
|
-
for (const entry of entries) {
|
|
78
|
-
const currPath = src + '/' + entry.name,
|
|
79
|
-
currDest = dest + '/' + entry.name,
|
|
80
|
-
ext = path.extname(entry.name);
|
|
81
|
-
if (entry.isFile() && !excludeExt?.includes(ext)) {
|
|
82
|
-
const req = fs.copy(currPath, currDest);
|
|
83
|
-
copyReqs.push(req);
|
|
84
|
-
} else if (entry.isDirectory()) {
|
|
85
|
-
const req = copyFilesRec(currPath, currDest, excludeExt);
|
|
86
|
-
copyReqs.push(req);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
} catch (error) {
|
|
90
|
-
logger.err(`Error searching in ${src}: ` + String(error));
|
|
91
|
-
}
|
|
92
|
-
await Promise.all(copyReqs);
|
|
93
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import jetEnv, { num } from 'jet-env';
|
|
2
|
-
import { isValueOf } from 'jet-validators';
|
|
3
|
-
|
|
4
|
-
import { NODE_ENVS } from '.';
|
|
5
|
-
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Setup
|
|
8
|
-
******************************************************************************/
|
|
9
|
-
|
|
10
|
-
const ENV = jetEnv({
|
|
11
|
-
NodeEnv: isValueOf(NODE_ENVS),
|
|
12
|
-
Port: num,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
/******************************************************************************
|
|
16
|
-
Export default
|
|
17
|
-
******************************************************************************/
|
|
18
|
-
|
|
19
|
-
export default ENV;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
|
|
3
|
-
import { ValueOf } from 'jet-validators';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Hypertext Transfer Protocol (HTTP) response status codes.
|
|
8
|
-
* @see {@link https://en.wikipedia.org/wiki/List_of_HTTP_status_codes}
|
|
9
|
-
*
|
|
10
|
-
* This file was copied from here: https://gist.github.com/scokmen/f813c904ef79022e84ab2409574d1b45
|
|
11
|
-
*/
|
|
12
|
-
const HTTP_STATUS_CODES = {
|
|
13
|
-
Continue: 100,
|
|
14
|
-
SwitchingProtocols: 101,
|
|
15
|
-
Processing: 102,
|
|
16
|
-
Ok: 200,
|
|
17
|
-
Created: 201,
|
|
18
|
-
Accepted: 202,
|
|
19
|
-
NonAuthoritativeInformation: 203,
|
|
20
|
-
NoContent: 204,
|
|
21
|
-
ResetContent: 205,
|
|
22
|
-
PartialContent: 206,
|
|
23
|
-
MultiStatus: 207,
|
|
24
|
-
AlreadyReported: 208,
|
|
25
|
-
ImUsed: 226,
|
|
26
|
-
MultipleChoices: 300,
|
|
27
|
-
MovedPermanently: 301,
|
|
28
|
-
Found: 302,
|
|
29
|
-
SeeOther: 303,
|
|
30
|
-
NotModified: 304,
|
|
31
|
-
UseProxy: 305,
|
|
32
|
-
SwitchProxy: 306,
|
|
33
|
-
TemporaryRedirect: 307,
|
|
34
|
-
PermanentRedirect: 308,
|
|
35
|
-
BadRequest: 400,
|
|
36
|
-
Unauthorized: 401,
|
|
37
|
-
PaymentRequired: 402,
|
|
38
|
-
Forbidden: 403,
|
|
39
|
-
NotFound: 404,
|
|
40
|
-
MethodNotAllowed: 405,
|
|
41
|
-
NotAcceptable: 406,
|
|
42
|
-
ProxyAuthenticationRequired: 407,
|
|
43
|
-
RequestTimeout: 408,
|
|
44
|
-
Conflict: 409,
|
|
45
|
-
Gone: 410,
|
|
46
|
-
LengthRequired: 411,
|
|
47
|
-
PreconditionFailed: 412,
|
|
48
|
-
PayloadTooLarge: 413,
|
|
49
|
-
UriTooLong: 414,
|
|
50
|
-
UnsupportedMediaType: 415,
|
|
51
|
-
RangeNotSatisfiable: 416,
|
|
52
|
-
ExpectationFailed: 417,
|
|
53
|
-
IamaTeapot: 418,
|
|
54
|
-
MisdirectedRequest: 421,
|
|
55
|
-
UnprocessableEntity: 422,
|
|
56
|
-
Locked: 423,
|
|
57
|
-
FailedDependency: 424,
|
|
58
|
-
UpgradeRequired: 426,
|
|
59
|
-
PreconditionRequired: 428,
|
|
60
|
-
TooManyRequests: 429,
|
|
61
|
-
RequestHeaderFieldsTooLarge: 431,
|
|
62
|
-
UnavailableForLegalReasons: 451,
|
|
63
|
-
InternalServerError: 500,
|
|
64
|
-
NotImplemented: 501,
|
|
65
|
-
BadGateway: 502,
|
|
66
|
-
ServiceUnavailable: 503,
|
|
67
|
-
GatewayTimeout: 504,
|
|
68
|
-
HttpVersionNotSupported: 505,
|
|
69
|
-
VariantAlsoNegotiates: 506,
|
|
70
|
-
InsuffientStorage: 507,
|
|
71
|
-
LoopDetected: 508,
|
|
72
|
-
NotExtended: 510,
|
|
73
|
-
NetworkAuthenticationRequired: 511,
|
|
74
|
-
} as const;
|
|
75
|
-
|
|
76
|
-
/******************************************************************************
|
|
77
|
-
Export default
|
|
78
|
-
******************************************************************************/
|
|
79
|
-
|
|
80
|
-
export type HttpStatusCodes = ValueOf<typeof HTTP_STATUS_CODES>;
|
|
81
|
-
export default HTTP_STATUS_CODES;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import jetPaths from 'jet-paths';
|
|
2
|
-
|
|
3
|
-
const PATHS = {
|
|
4
|
-
_: '/api',
|
|
5
|
-
Users: {
|
|
6
|
-
_: '/users',
|
|
7
|
-
Get: '/all',
|
|
8
|
-
Add: '/add',
|
|
9
|
-
Update: '/update',
|
|
10
|
-
Delete: '/delete/:id',
|
|
11
|
-
},
|
|
12
|
-
} as const;
|
|
13
|
-
|
|
14
|
-
export const JET_PATHS = jetPaths(PATHS);
|
|
15
|
-
export default PATHS;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/******************************************************************************
|
|
3
|
-
Constants
|
|
4
|
-
******************************************************************************/
|
|
5
|
-
|
|
6
|
-
// NOTE: These need to match the names of your ".env" files
|
|
7
|
-
export const NODE_ENVS = {
|
|
8
|
-
Dev: 'development',
|
|
9
|
-
Test: 'test',
|
|
10
|
-
Production: 'production',
|
|
11
|
-
} as const;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/******************************************************************************
|
|
3
|
-
Functions
|
|
4
|
-
******************************************************************************/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get a random number between 1 and 1,000,000,000,000
|
|
8
|
-
*/
|
|
9
|
-
export function getRandomInt(): number {
|
|
10
|
-
return Math.floor(Math.random() * 1_000_000_000_000);
|
|
11
|
-
}
|