Skip to content

Commit 258bdda

Browse files
committed
feat: 🎸 initial commit
this commit include the initial version of express-boilerplate-generator
0 parents  commit 258bdda

File tree

88 files changed

+12055
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+12055
-0
lines changed

Diff for: .eslintrc.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
env:
2+
browser: true
3+
commonjs: true
4+
es2020: true
5+
extends: 'eslint:recommended'
6+
parserOptions:
7+
ecmaVersion: 11
8+
rules:
9+
no-useless-catch: 'off'
10+
no-undef: 'off'
11+
indent:
12+
- error
13+
- tab
14+
linebreak-style: 'off'
15+
quotes:
16+
- error
17+
- single
18+
semi:
19+
- error
20+
- always

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
./**/node_modules

Diff for: .npmignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
./**/node_modules
3+
coverage
4+
./**/coverage

Diff for: .snyk

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
2+
version: v1.14.1
3+
ignore: {}
4+
patch: {}

Diff for: CONTRIBUTING.md

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface.
13+
3. Increase the version numbers in any examples files and the README.md, Package.json to the new version that this
14+
Pull Request would represent.
15+
4. Use `npm run commit-a` to add and commit changes.
16+
17+
## Code of Conduct
18+
19+
### Our Pledge
20+
21+
In the interest of fostering an open and welcoming environment, we as
22+
contributors and maintainers pledge to making participation in our project and
23+
our community a harassment-free experience for everyone, regardless of age, body
24+
size, disability, ethnicity, gender identity and expression, level of experience,
25+
nationality, personal appearance, race, religion, or sexual identity and
26+
orientation.
27+
28+
### Our Standards
29+
30+
Examples of behavior that contributes to creating a positive environment
31+
include:
32+
33+
* Using welcoming and inclusive language
34+
* Being respectful of differing viewpoints and experiences
35+
* Gracefully accepting constructive criticism
36+
* Focusing on what is best for the community
37+
* Showing empathy towards other community members
38+
39+
Examples of unacceptable behavior by participants include:
40+
41+
* The use of sexualized language or imagery and unwelcome sexual attention or
42+
advances
43+
* Trolling, insulting/derogatory comments, and personal or political attacks
44+
* Public or private harassment
45+
* Publishing others' private information, such as a physical or electronic
46+
address, without explicit permission
47+
* Other conduct which could reasonably be considered inappropriate in a
48+
professional setting
49+
50+
### Our Responsibilities
51+
52+
Project maintainers are responsible for clarifying the standards of acceptable
53+
behavior and are expected to take appropriate and fair corrective action in
54+
response to any instances of unacceptable behavior.
55+
56+
Project maintainers have the right and responsibility to remove, edit, or
57+
reject comments, commits, code, wiki edits, issues, and other contributions
58+
that are not aligned to this Code of Conduct, or to ban temporarily or
59+
permanently any contributor for other behaviors that they deem inappropriate,
60+
threatening, offensive, or harmful.
61+
62+
### Scope
63+
64+
This Code of Conduct applies both within project spaces and in public spaces
65+
when an individual is representing the project or its community. Examples of
66+
representing a project or community include using an official project e-mail
67+
address, posting via an official social media account, or acting as an appointed
68+
representative at an online or offline event. Representation of a project may be
69+
further defined and clarified by project maintainers.
70+
71+
### Enforcement
72+
73+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
74+
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
75+
complaints will be reviewed and investigated and will result in a response that
76+
is deemed necessary and appropriate to the circumstances. The project team is
77+
obligated to maintain confidentiality with regard to the reporter of an incident.
78+
Further details of specific enforcement policies may be posted separately.
79+
80+
Project maintainers who do not follow or enforce the Code of Conduct in good
81+
faith may face temporary or permanent repercussions as determined by other
82+
members of the project's leadership.
83+
84+
### Attribution
85+
86+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
87+
available at [http://contributor-covenant.org/version/1/4][version]
88+
89+
[homepage]: http://contributor-covenant.org
90+
[version]: http://contributor-covenant.org/version/1/4/

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Sean Maxwell
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Diff for: README.md

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<h1 align="center">welcome to express-boilerplate-generator 👋</h1>
2+
<p>
3+
<img alt="Version" src="https://img.shields.io/github/package-json/v/open-devs/express-boilerplate-generator" />
4+
<a href="https://www.npmjs.com/package/express-boilerplate-generator" target="_blank">
5+
<img alt="npm" src="https://img.shields.io/npm/v/express-boilerplate-generator">
6+
</a>
7+
<img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/express-boilerplate-generator">
8+
<img alt="npm" src="https://img.shields.io/npm/dm/express-boilerplate-generator">
9+
<a href="https://github.com/open-devs/express-boilerplate-generator#readme" target="_blank">
10+
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-blue.svg" />
11+
</a>
12+
<a href="https://github.com/open-devs/express-boilerplate-generator/graphs/commit-activity" target="_blank">
13+
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained-yes-blue.svg" />
14+
</a>
15+
<a href="https://github.com/open-devs/express-boilerplate-generator/blob/master/LICENSE" target="_blank">
16+
<img alt="License: MIT" src="https://img.shields.io/npm/l/express-boilerplate-generator" />
17+
<img alt="Snyk Vulnerabilities for npm package" src="https://img.shields.io/snyk/vulnerabilities/npm/express-boilerplate-generator">
18+
</a>
19+
</p>
20+
21+
> generates new [express](https://expressjs.com/) applications in everyone's favourite language [typescript](https://github.com/microsoft/TypeScript) with various options to choose from based on your project needs
22+
23+
### 🏠 [homepage](https://github.com/open-devs/express-boilerplate-generator#readme)
24+
25+
### 📰 [npm](https://www.npmjs.com/package/express-boilerplate-generator)
26+
27+
## install
28+
29+
```sh
30+
$ npm i -g express-boilerplate-generator
31+
```
32+
33+
## usage
34+
35+
Run anyone of following commands:
36+
37+
```sh
38+
$ express-gen
39+
# or
40+
$ express-typescript-generator
41+
# or
42+
$ express-ts-gen
43+
```
44+
45+
Or, to avoid installation and usage simply use the following command:
46+
47+
```sh
48+
$ npx express-boilerplate-generator
49+
```
50+
51+
## ❓ what is it
52+
53+
creates a new express application as a starter boilerplate similar to the express-gen module. except this new application is configured to use typeScript instead of plain javascript and provides various options such as, kind of project structure to use with focus on auth support along with documentaion to fasten the development process.
54+
55+
## 🤔 why express-boilerplate-generator
56+
57+
nodejs is great for the rapid development of web-projects, but is often neglected because of the lack of type safety. typescript solves this issue and (along with its linter file) can even make your code more robust than some other static languages like java.
58+
59+
there are some other tools out there to generate express apps with javascript such as Express application generator, but these either haven't been updated in a while or don't support typescript or don't have pre-added documentation support.
60+
61+
in this application you have two options to setup a project either with or without auth.
62+
63+
## 📜 different options available explained
64+
65+
<table>
66+
<caption>description of various options available</caption>
67+
<thead>
68+
<tr>
69+
<th>name</th>
70+
<th>description</th>
71+
</tr>
72+
</thead>
73+
<tbody>
74+
<tr>
75+
<td>express-server-boilerplate</td>
76+
<td>this type of structure provides auth-less express server boilerplate codes to kickstart your backend development along with the support of typedoc & swagger.</td>
77+
</tr>
78+
<tr>
79+
<td>express-server-boilerplate-auth</td>
80+
<td>this type of structure provides express server boilerplate codes to kickstart your backend development with authentication support. It uses passport-jwt and passport as dependency.</td>
81+
</tr>
82+
</tbody>
83+
</table>
84+
<br>
85+
86+
happy app-deving 😊
87+
88+
## 👤 author
89+
90+
**open devs ([email protected])**
91+
92+
* website: https://opendevs.in/
93+
* github: [@open-devs](https://github.com/open-devs)
94+
* core members: [@alok722](https://github.com/alok722), [@mikr13](https://github.com/mikr13)
95+
96+
## 🚀 future scope
97+
98+
* adding docker & container configurations
99+
* adding template support
100+
* more template structures
101+
102+
## 🤝 contributing
103+
104+
contributions, issues and feature requests are welcome!<br />feel free to check [issues page](https://github.com/open-devs/fastify-typescript-generator/issues). you can also take a look at the [contributing guide](https://github.com/open-devs/fastify-typescript-generator/blob/master/CONTRIBUTING.md).
105+
106+
## 🙌 show your support
107+
108+
give a ⭐️ if this project helped you!
109+
110+
<a href="https://www.buymeacoffee.com/opendevs" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
111+
112+
## 📝 license
113+
114+
copyright © 2020 [open devs ([email protected])](https://github.com/open-devs).<br />
115+
This project is [MIT](https://github.com/open-devs/express-boilerplate-generator/blob/master/LICENSE) licensed.
116+
117+
***
118+
_this README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_

Diff for: bin/express-boilerplate-generator.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('../lib/cli');

Diff for: lib/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

Diff for: lib/cli.js

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env node
2+
3+
const path = require('path');
4+
const expressGenTs = require('./express-generator');
5+
const { prompt } = require('prompts');
6+
const { say } = require('cfonts');
7+
8+
const options = [
9+
{
10+
description: 'Express Server Boilerplate without Auth',
11+
defaultName: 'express-server-boilerplate',
12+
templateName: 'express-server-boilerplate',
13+
dependencies: 'cookie-parser dotenv express express-async-errors helmet mongoose morgan snyk swagger-ui-express',
14+
devDependencies: '@types/express @types/cookie-parser @types/find @types/helmet @types/jsonfile @types/mongoose @types/morgan @types/node @types/swagger-ui-express @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint find fs-extra git-cz jsonfile nodemon ts-node tsconfig-paths typedoc typescript'
15+
}, {
16+
description: 'Express Server Boilerplate with Auth',
17+
defaultName: 'express-server-boilerplate-auth',
18+
templateName: 'express-server-boilerplate-auth',
19+
dependencies: 'bcryptjs cookie-parser dotenv express express-async-errors helmet mongoose morgan passport passport-jwt passport-local',
20+
devDependencies: '@types/express @types/cookie-parser @types/passport @types/bcryptjs @types/find @types/helmet @types/jsonfile @types/mongoose @types/morgan @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint find fs-extra git-cz jsonfile nodemon ts-node tsconfig-paths typescript @types/passport-jwt'
21+
}
22+
];
23+
24+
25+
const getDest = (option, destFolder, projectName) => {
26+
return `${path.join(process.cwd(), destFolder)}/${projectName || option.defaultName}`;
27+
};
28+
29+
30+
const initiate = async (option, path, projectName) => {
31+
try {
32+
const destination = getDest(option, path, projectName);
33+
await expressGenTs(option, destination);
34+
console.log('\x1b[32m\x1b[40m%s\x1b[0m', `Project setup complete! at ${destination}`);
35+
} catch (error) {
36+
console.error(error);
37+
}
38+
};
39+
40+
41+
say('express server generator', {
42+
font: 'chrome',
43+
align: 'center',
44+
colors: ['system'],
45+
background: 'transparent',
46+
letterSpacing: 1,
47+
lineHeight: 1,
48+
space: true,
49+
});
50+
51+
52+
say('opendevs', {
53+
font: 'chrome',
54+
align: 'right',
55+
colors: ['system'],
56+
background: 'transparent',
57+
letterSpacing: 1,
58+
lineHeight: 1,
59+
space: true,
60+
gradient: ['#fff', '#89d8d3'],
61+
});
62+
63+
64+
console.log('\x1b[33m\x1b[40m%s\x1b[0m', 'Setting up new Express Server Boilerplate project...\n');
65+
66+
67+
const onCancel = () => {
68+
console.log('\x1b[31m%s\x1b[0m', 'Project creation failed!');
69+
};
70+
71+
72+
(async () => {
73+
const questions = [
74+
{
75+
type: 'select',
76+
name: 'option',
77+
message: 'Select a option for the type of project',
78+
validate: value => value >= 1 && value <=2 ? true : 'Specify number in the range of 1 - 2',
79+
suggest: (input, choices) => choices.filter(i => i.value),
80+
choices: options.map((el, index) => ({ value: index, title: el.templateName, description: el.description })),
81+
fallback: {
82+
title: 'Using default',
83+
value: 1
84+
}
85+
},
86+
{
87+
type: 'text',
88+
name: 'projectName',
89+
message: 'Specify project name',
90+
validate: projectName => /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName) ? true : 'Invalid project name, please follow npm guidelines'
91+
},
92+
{
93+
type: 'text',
94+
name: 'path',
95+
message: '[OPTIONAL] Specify directory where you want to create the project, if no path is provided current directory will be used.',
96+
fallback: {
97+
title: 'Using default',
98+
value: './'
99+
}
100+
}
101+
];
102+
103+
const answers = await prompt(questions, { onCancel });
104+
105+
if (answers.option, answers.path, answers.projectName) {
106+
console.log('\x1b[33m\x1b[40m%s\x1b[0m', 'Let\'s get started...');
107+
initiate(options[answers.option], answers.path, answers.projectName);
108+
}
109+
110+
111+
})();

0 commit comments

Comments
 (0)