Skip to content

Commit

Permalink
feat: 🎸 initial commit
Browse files Browse the repository at this point in the history
this commit include the initial version of express-boilerplate-generator
  • Loading branch information
alok722 committed Nov 23, 2020
0 parents commit 258bdda
Show file tree
Hide file tree
Showing 88 changed files with 12,055 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
env:
browser: true
commonjs: true
es2020: true
extends: 'eslint:recommended'
parserOptions:
ecmaVersion: 11
rules:
no-useless-catch: 'off'
no-undef: 'off'
indent:
- error
- tab
linebreak-style: 'off'
quotes:
- error
- single
semi:
- error
- always
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
./**/node_modules
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
./**/node_modules
coverage
./**/coverage
4 changes: 4 additions & 0 deletions .snyk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.14.1
ignore: {}
patch: {}
90 changes: 90 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change.

Please note we have a code of conduct, please follow it in all your interactions with the project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface.
3. Increase the version numbers in any examples files and the README.md, Package.json to the new version that this
Pull Request would represent.
4. Use `npm run commit-a` to add and commit changes.

## Code of Conduct

### Our Pledge

In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.

### Our Standards

Examples of behavior that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting

### Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

### Scope

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.

### Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at [INSERT EMAIL ADDRESS]. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.

### Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Sean Maxwell

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
118 changes: 118 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<h1 align="center">welcome to express-boilerplate-generator 👋</h1>
<p>
<img alt="Version" src="https://img.shields.io/github/package-json/v/open-devs/express-boilerplate-generator" />
<a href="https://www.npmjs.com/package/express-boilerplate-generator" target="_blank">
<img alt="npm" src="https://img.shields.io/npm/v/express-boilerplate-generator">
</a>
<img alt="npm bundle size" src="https://img.shields.io/bundlephobia/minzip/express-boilerplate-generator">
<img alt="npm" src="https://img.shields.io/npm/dm/express-boilerplate-generator">
<a href="https://github.com/open-devs/express-boilerplate-generator#readme" target="_blank">
<img alt="Documentation" src="https://img.shields.io/badge/documentation-yes-blue.svg" />
</a>
<a href="https://github.com/open-devs/express-boilerplate-generator/graphs/commit-activity" target="_blank">
<img alt="Maintenance" src="https://img.shields.io/badge/Maintained-yes-blue.svg" />
</a>
<a href="https://github.com/open-devs/express-boilerplate-generator/blob/master/LICENSE" target="_blank">
<img alt="License: MIT" src="https://img.shields.io/npm/l/express-boilerplate-generator" />
<img alt="Snyk Vulnerabilities for npm package" src="https://img.shields.io/snyk/vulnerabilities/npm/express-boilerplate-generator">
</a>
</p>

> 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
### 🏠 [homepage](https://github.com/open-devs/express-boilerplate-generator#readme)

### 📰 [npm](https://www.npmjs.com/package/express-boilerplate-generator)

## install

```sh
$ npm i -g express-boilerplate-generator
```

## usage

Run anyone of following commands:

```sh
$ express-gen
# or
$ express-typescript-generator
# or
$ express-ts-gen
```

Or, to avoid installation and usage simply use the following command:

```sh
$ npx express-boilerplate-generator
```

## ❓ what is it

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.

## 🤔 why express-boilerplate-generator

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.

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.

in this application you have two options to setup a project either with or without auth.

## 📜 different options available explained

<table>
<caption>description of various options available</caption>
<thead>
<tr>
<th>name</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>express-server-boilerplate</td>
<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>
</tr>
<tr>
<td>express-server-boilerplate-auth</td>
<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>
</tr>
</tbody>
</table>
<br>

happy app-deving 😊

## 👤 author

**open devs ([email protected])**

* website: https://opendevs.in/
* github: [@open-devs](https://github.com/open-devs)
* core members: [@alok722](https://github.com/alok722), [@mikr13](https://github.com/mikr13)

## 🚀 future scope

* adding docker & container configurations
* adding template support
* more template structures

## 🤝 contributing

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).

## 🙌 show your support

give a ⭐️ if this project helped you!

<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>

## 📝 license

copyright © 2020 [open devs ([email protected])](https://github.com/open-devs).<br />
This project is [MIT](https://github.com/open-devs/express-boilerplate-generator/blob/master/LICENSE) licensed.

***
_this README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_
3 changes: 3 additions & 0 deletions bin/express-boilerplate-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('../lib/cli');
1 change: 1 addition & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
111 changes: 111 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/usr/bin/env node

const path = require('path');
const expressGenTs = require('./express-generator');
const { prompt } = require('prompts');
const { say } = require('cfonts');

const options = [
{
description: 'Express Server Boilerplate without Auth',
defaultName: 'express-server-boilerplate',
templateName: 'express-server-boilerplate',
dependencies: 'cookie-parser dotenv express express-async-errors helmet mongoose morgan snyk swagger-ui-express',
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'
}, {
description: 'Express Server Boilerplate with Auth',
defaultName: 'express-server-boilerplate-auth',
templateName: 'express-server-boilerplate-auth',
dependencies: 'bcryptjs cookie-parser dotenv express express-async-errors helmet mongoose morgan passport passport-jwt passport-local',
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'
}
];


const getDest = (option, destFolder, projectName) => {
return `${path.join(process.cwd(), destFolder)}/${projectName || option.defaultName}`;
};


const initiate = async (option, path, projectName) => {
try {
const destination = getDest(option, path, projectName);
await expressGenTs(option, destination);
console.log('\x1b[32m\x1b[40m%s\x1b[0m', `Project setup complete! at ${destination}`);
} catch (error) {
console.error(error);
}
};


say('express server generator', {
font: 'chrome',
align: 'center',
colors: ['system'],
background: 'transparent',
letterSpacing: 1,
lineHeight: 1,
space: true,
});


say('opendevs', {
font: 'chrome',
align: 'right',
colors: ['system'],
background: 'transparent',
letterSpacing: 1,
lineHeight: 1,
space: true,
gradient: ['#fff', '#89d8d3'],
});


console.log('\x1b[33m\x1b[40m%s\x1b[0m', 'Setting up new Express Server Boilerplate project...\n');


const onCancel = () => {
console.log('\x1b[31m%s\x1b[0m', 'Project creation failed!');
};


(async () => {
const questions = [
{
type: 'select',
name: 'option',
message: 'Select a option for the type of project',
validate: value => value >= 1 && value <=2 ? true : 'Specify number in the range of 1 - 2',
suggest: (input, choices) => choices.filter(i => i.value),
choices: options.map((el, index) => ({ value: index, title: el.templateName, description: el.description })),
fallback: {
title: 'Using default',
value: 1
}
},
{
type: 'text',
name: 'projectName',
message: 'Specify project name',
validate: projectName => /^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/.test(projectName) ? true : 'Invalid project name, please follow npm guidelines'
},
{
type: 'text',
name: 'path',
message: '[OPTIONAL] Specify directory where you want to create the project, if no path is provided current directory will be used.',
fallback: {
title: 'Using default',
value: './'
}
}
];

const answers = await prompt(questions, { onCancel });

if (answers.option, answers.path, answers.projectName) {
console.log('\x1b[33m\x1b[40m%s\x1b[0m', 'Let\'s get started...');
initiate(options[answers.option], answers.path, answers.projectName);
}


})();
Loading

0 comments on commit 258bdda

Please sign in to comment.