create-nodejs-express-starter 1.7.0 → 1.7.1
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/.gitattributes +3 -0
- package/.github/FUNDING.yml +15 -0
- package/.github/workflows/ci.yml +62 -0
- package/.github/workflows/npm-publish.yml +36 -0
- package/.husky/post-checkout +4 -0
- package/.husky/post-commit +1 -0
- package/.husky/pre-commit +8 -0
- package/.lintstagedrc.json +3 -0
- package/.travis.yml +20 -0
- package/README.md +1 -6
- package/bin/createNodejsApp.js +8 -9
- package/package.json +2 -25
- package/.gitignore +0 -14
package/.gitattributes
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: Ahlyab
|
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
|
12
|
+
polar: # Replace with a single Polar username
|
|
13
|
+
buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
|
14
|
+
thanks_dev: # Replace with a single thanks.dev username
|
|
15
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
lint-and-test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
node-version: [18.x, 20.x]
|
|
15
|
+
|
|
16
|
+
services:
|
|
17
|
+
mongodb:
|
|
18
|
+
image: mongo:6
|
|
19
|
+
ports:
|
|
20
|
+
- 27017:27017
|
|
21
|
+
options: >-
|
|
22
|
+
--health-cmd "mongosh --eval 'db.runCommand({ ping: 1 })'"
|
|
23
|
+
--health-interval 10s
|
|
24
|
+
--health-timeout 5s
|
|
25
|
+
--health-retries 5
|
|
26
|
+
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
|
|
30
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
31
|
+
uses: actions/setup-node@v4
|
|
32
|
+
with:
|
|
33
|
+
node-version: ${{ matrix.node-version }}
|
|
34
|
+
cache: 'npm'
|
|
35
|
+
|
|
36
|
+
- name: Install dependencies
|
|
37
|
+
run: npm ci
|
|
38
|
+
|
|
39
|
+
- name: Run linter
|
|
40
|
+
run: npm run lint
|
|
41
|
+
|
|
42
|
+
- name: Run tests
|
|
43
|
+
run: npm test
|
|
44
|
+
env:
|
|
45
|
+
NODE_ENV: test
|
|
46
|
+
MONGODB_URL: mongodb://localhost:27017/node-boilerplate-test
|
|
47
|
+
JWT_SECRET: test-secret-key
|
|
48
|
+
|
|
49
|
+
- name: Run tests with coverage
|
|
50
|
+
run: npm run coverage
|
|
51
|
+
env:
|
|
52
|
+
NODE_ENV: test
|
|
53
|
+
MONGODB_URL: mongodb://localhost:27017/node-boilerplate-test
|
|
54
|
+
JWT_SECRET: test-secret-key
|
|
55
|
+
|
|
56
|
+
- name: Coveralls GitHub Action
|
|
57
|
+
uses: coverallsapp/github-action@v2.3.6
|
|
58
|
+
with:
|
|
59
|
+
path-to-lcov: ./coverage/lcov.info
|
|
60
|
+
env:
|
|
61
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
62
|
+
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Publish to npm on main
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
name: publish
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Use Node.js
|
|
21
|
+
uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: 20
|
|
24
|
+
registry-url: https://registry.npmjs.org
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: Lint
|
|
30
|
+
run: npm run lint
|
|
31
|
+
|
|
32
|
+
- name: Publish to npm
|
|
33
|
+
env:
|
|
34
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
35
|
+
run: npm publish --access public
|
|
36
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
git status
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# 1. Check for high/critical vulnerabilities (production deps only; coveralls/pm2 may have no fix)
|
|
2
|
+
npm audit --audit-level=high --omit=dev
|
|
3
|
+
|
|
4
|
+
# 2. Lint entire codebase
|
|
5
|
+
npm run lint
|
|
6
|
+
|
|
7
|
+
# 3. Lint and format staged files (eslint --fix + prettier --write)
|
|
8
|
+
npx --no-install lint-staged || npx lint-staged
|
package/.travis.yml
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
language: node_js
|
|
2
|
+
node_js:
|
|
3
|
+
- '12'
|
|
4
|
+
services:
|
|
5
|
+
- mongodb
|
|
6
|
+
cache: yarn
|
|
7
|
+
branches:
|
|
8
|
+
only:
|
|
9
|
+
- master
|
|
10
|
+
env:
|
|
11
|
+
global:
|
|
12
|
+
- PORT=3000
|
|
13
|
+
- MONGODB_URL=mongodb://localhost:27017/node-boilerplate
|
|
14
|
+
- JWT_SECRET=thisisasamplesecret
|
|
15
|
+
- JWT_ACCESS_EXPIRATION_MINUTES=30
|
|
16
|
+
- JWT_REFRESH_EXPIRATION_DAYS=30
|
|
17
|
+
script:
|
|
18
|
+
- yarn lint
|
|
19
|
+
- yarn test
|
|
20
|
+
# Coverage is reported via GitHub Actions (see .github/workflows/ci.yml)
|
package/README.md
CHANGED
|
@@ -12,14 +12,9 @@ By running a single command, you will get a production-ready Node.js app install
|
|
|
12
12
|
To create and initialize a new project in one command:
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npx nodejs-express-
|
|
15
|
+
npx create-nodejs-express-app <project-name>
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
Or:
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
npm init nodejs-express-starter <project-name>
|
|
22
|
-
```
|
|
23
18
|
|
|
24
19
|
This will create a new folder with the project name, copy the template, install dependencies (`npm install`), and set up `.env` from `.env.example`. Then:
|
|
25
20
|
|
package/bin/createNodejsApp.js
CHANGED
|
@@ -28,8 +28,8 @@ function copyRecursive(src, dest, templateRoot, excludeDirName) {
|
|
|
28
28
|
function main() {
|
|
29
29
|
const projectName = process.argv[2];
|
|
30
30
|
if (!projectName) {
|
|
31
|
-
console.error('Usage: npx nodejs-express-
|
|
32
|
-
console.error('Example: npx nodejs-express-
|
|
31
|
+
console.error('Usage: npx create-nodejs-express-app <project-name>');
|
|
32
|
+
console.error('Example: npx create-nodejs-express-app my-api');
|
|
33
33
|
process.exit(1);
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -49,7 +49,7 @@ function main() {
|
|
|
49
49
|
if (err.code === 'EACCES') {
|
|
50
50
|
console.error(`Error: Permission denied creating folder at ${targetDir}`);
|
|
51
51
|
console.error('Run the command from a directory you can write to (e.g. your home or Desktop):');
|
|
52
|
-
console.error(` cd ~/Desktop && npx nodejs-express-
|
|
52
|
+
console.error(` cd ~/Desktop && npx create-nodejs-express-app ${projectName}`);
|
|
53
53
|
} else {
|
|
54
54
|
console.error(`Error: ${err.message}`);
|
|
55
55
|
}
|
|
@@ -82,12 +82,11 @@ function main() {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
console.log('Installing dependencies...');
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
});
|
|
85
|
+
const install = spawnSync('npm', ['install'], {
|
|
86
|
+
cwd: targetDir,
|
|
87
|
+
stdio: 'inherit',
|
|
88
|
+
shell: true,
|
|
89
|
+
});
|
|
91
90
|
if (install.status !== 0) {
|
|
92
91
|
console.error('npm install failed. You can run it manually inside the project.');
|
|
93
92
|
process.exit(install.status || 1);
|
package/package.json
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-nodejs-express-starter",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Create a Node.js app for building production-ready RESTful APIs using Express, by running one command",
|
|
5
|
-
"bin":
|
|
6
|
-
"create-nodejs-express-starter": "./bin/createNodejsApp.js"
|
|
7
|
-
},
|
|
5
|
+
"bin": "bin/createNodejsApp.js",
|
|
8
6
|
"main": "src/index.js",
|
|
9
7
|
"repository": "https://github.com/Ahlyab/express-backend-starter-js.git",
|
|
10
8
|
"author": "Ahlyab <ahalyabasad@gmail.com>",
|
|
11
9
|
"license": "MIT",
|
|
12
|
-
"files": [
|
|
13
|
-
"bin",
|
|
14
|
-
"src",
|
|
15
|
-
"tests",
|
|
16
|
-
".env.example",
|
|
17
|
-
".gitignore",
|
|
18
|
-
".eslintrc.json",
|
|
19
|
-
".eslintignore",
|
|
20
|
-
".prettierrc.json",
|
|
21
|
-
".prettierignore",
|
|
22
|
-
".editorconfig",
|
|
23
|
-
"docker-compose.yml",
|
|
24
|
-
"docker-compose.dev.yml",
|
|
25
|
-
"docker-compose.prod.yml",
|
|
26
|
-
"docker-compose.test.yml",
|
|
27
|
-
"Dockerfile",
|
|
28
|
-
".dockerignore",
|
|
29
|
-
"jest.config.js",
|
|
30
|
-
"LICENSE",
|
|
31
|
-
"README.md"
|
|
32
|
-
],
|
|
33
10
|
"engines": {
|
|
34
11
|
"node": ">=18.0.0"
|
|
35
12
|
},
|