clwy-express-generator 4.16.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.
Files changed (45) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +115 -0
  3. package/bin/express-cli.js +595 -0
  4. package/package.json +68 -0
  5. package/templates/.env.ejs +12 -0
  6. package/templates/css/style.css +8 -0
  7. package/templates/css/style.less +8 -0
  8. package/templates/css/style.sass +6 -0
  9. package/templates/css/style.scss +10 -0
  10. package/templates/css/style.styl +5 -0
  11. package/templates/js/app.js.ejs +44 -0
  12. package/templates/js/config/routes.js +10 -0
  13. package/templates/js/gitignore +61 -0
  14. package/templates/js/index.html +13 -0
  15. package/templates/js/routes/index.js +11 -0
  16. package/templates/js/routes/users.js +9 -0
  17. package/templates/js/www.ejs +90 -0
  18. package/templates/middlewares/error-handler.js +17 -0
  19. package/templates/mjs/app.js.ejs +48 -0
  20. package/templates/mjs/config/routes.js +10 -0
  21. package/templates/mjs/routes/index.js +11 -0
  22. package/templates/mjs/routes/users.js +9 -0
  23. package/templates/mjs/www.ejs +92 -0
  24. package/templates/prisma/schema.prisma +14 -0
  25. package/templates/views/error.dust +12 -0
  26. package/templates/views/error.ejs +3 -0
  27. package/templates/views/error.hbs +3 -0
  28. package/templates/views/error.hjs +3 -0
  29. package/templates/views/error.jade +6 -0
  30. package/templates/views/error.pug +6 -0
  31. package/templates/views/error.twig +7 -0
  32. package/templates/views/error.vash +7 -0
  33. package/templates/views/index.dust +11 -0
  34. package/templates/views/index.ejs +11 -0
  35. package/templates/views/index.hbs +2 -0
  36. package/templates/views/index.hjs +11 -0
  37. package/templates/views/index.jade +5 -0
  38. package/templates/views/index.pug +5 -0
  39. package/templates/views/index.twig +6 -0
  40. package/templates/views/index.vash +6 -0
  41. package/templates/views/layout.hbs +10 -0
  42. package/templates/views/layout.jade +7 -0
  43. package/templates/views/layout.pug +7 -0
  44. package/templates/views/layout.twig +10 -0
  45. package/templates/views/layout.vash +11 -0
@@ -0,0 +1,5 @@
1
+ body
2
+ padding: 50px
3
+ font: 14px "Lucida Grande", Helvetica, Arial, sans-serif
4
+ a
5
+ color: #00B7FF
@@ -0,0 +1,44 @@
1
+ var express = require('express');
2
+ var path = require('path');
3
+ <% Object.keys(modules).sort().forEach(function (variable) { -%>
4
+ var <%- variable %> = require('<%- modules[variable] %>');
5
+ <% }); -%>
6
+
7
+ <% if (view) { -%>
8
+ var createError = require('http-errors');
9
+ var errorHandler = require('./middlewares/error-handler');
10
+ <% } -%>
11
+
12
+ // environment variables
13
+ require('dotenv').config();
14
+ var routes = require('./config/routes');
15
+
16
+ var app = express();
17
+
18
+ <% if (view) { -%>
19
+ // view engine setup
20
+ <% if (view.render) { -%>
21
+ app.engine('<%- view.engine %>', <%- view.render %>);
22
+ <% } -%>
23
+ app.set('views', path.join(__dirname, 'views'));
24
+ app.set('view engine', '<%- view.engine %>');
25
+
26
+ <% } -%>
27
+ <% uses.forEach(function (use) { -%>
28
+ app.use(<%- use %>);
29
+ <% }); -%>
30
+
31
+ // routes
32
+ app.use(routes);
33
+
34
+ <% if (view) { -%>
35
+ // catch 404 and forward to error handler
36
+ app.use(function(req, res, next) {
37
+ next(createError(404));
38
+ });
39
+
40
+ // error handler
41
+ app.use(errorHandler);
42
+
43
+ <% } -%>
44
+ module.exports = app;
@@ -0,0 +1,10 @@
1
+ const express = require('express');
2
+ const indexRouter = require('../routes/index.js');
3
+ const usersRouter = require('../routes/users.js');
4
+
5
+ const router = express.Router();
6
+
7
+ router.use('/', indexRouter);
8
+ router.use('/users', usersRouter);
9
+
10
+ module.exports = router;
@@ -0,0 +1,61 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+
8
+ # Runtime data
9
+ pids
10
+ *.pid
11
+ *.seed
12
+ *.pid.lock
13
+
14
+ # Directory for instrumented libs generated by jscoverage/JSCover
15
+ lib-cov
16
+
17
+ # Coverage directory used by tools like istanbul
18
+ coverage
19
+
20
+ # nyc test coverage
21
+ .nyc_output
22
+
23
+ # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24
+ .grunt
25
+
26
+ # Bower dependency directory (https://bower.io/)
27
+ bower_components
28
+
29
+ # node-waf configuration
30
+ .lock-wscript
31
+
32
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
33
+ build/Release
34
+
35
+ # Dependency directories
36
+ node_modules/
37
+ jspm_packages/
38
+
39
+ # Typescript v1 declaration files
40
+ typings/
41
+
42
+ # Optional npm cache directory
43
+ .npm
44
+
45
+ # Optional eslint cache
46
+ .eslintcache
47
+
48
+ # Optional REPL history
49
+ .node_repl_history
50
+
51
+ # Output of 'npm pack'
52
+ *.tgz
53
+
54
+ # Yarn Integrity file
55
+ .yarn-integrity
56
+
57
+ # dotenv environment variables file
58
+ .env
59
+
60
+ # next.js build output
61
+ .next
@@ -0,0 +1,13 @@
1
+ <html>
2
+
3
+ <head>
4
+ <title>Express</title>
5
+ <link rel="stylesheet" href="/stylesheets/style.css">
6
+ </head>
7
+
8
+ <body>
9
+ <h1>Express</h1>
10
+ <p>Welcome to Express</p>
11
+ </body>
12
+
13
+ </html>
@@ -0,0 +1,11 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+
4
+ /* GET home page. */
5
+ router.get('/', function(req, res, next) {
6
+ // if you want to use json, you can use res.json instead of res.render
7
+ // res.json({ title: 'Express' });
8
+ res.render('index', { title: 'Express' });
9
+ });
10
+
11
+ module.exports = router;
@@ -0,0 +1,9 @@
1
+ var express = require('express');
2
+ var router = express.Router();
3
+
4
+ /* GET users listing. */
5
+ router.get('/', function(req, res, next) {
6
+ res.send('respond with a resource');
7
+ });
8
+
9
+ module.exports = router;
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Module dependencies.
5
+ */
6
+
7
+ var app = require('../app');
8
+ var debug = require('debug')('<%- name %>:server');
9
+ var http = require('http');
10
+
11
+ /**
12
+ * Get port from environment and store in Express.
13
+ */
14
+
15
+ var port = normalizePort(process.env.PORT || '3000');
16
+ app.set('port', port);
17
+
18
+ /**
19
+ * Create HTTP server.
20
+ */
21
+
22
+ var server = http.createServer(app);
23
+
24
+ /**
25
+ * Listen on provided port, on all network interfaces.
26
+ */
27
+
28
+ server.listen(port);
29
+ server.on('error', onError);
30
+ server.on('listening', onListening);
31
+
32
+ /**
33
+ * Normalize a port into a number, string, or false.
34
+ */
35
+
36
+ function normalizePort(val) {
37
+ var port = parseInt(val, 10);
38
+
39
+ if (isNaN(port)) {
40
+ // named pipe
41
+ return val;
42
+ }
43
+
44
+ if (port >= 0) {
45
+ // port number
46
+ return port;
47
+ }
48
+
49
+ return false;
50
+ }
51
+
52
+ /**
53
+ * Event listener for HTTP server "error" event.
54
+ */
55
+
56
+ function onError(error) {
57
+ if (error.syscall !== 'listen') {
58
+ throw error;
59
+ }
60
+
61
+ var bind = typeof port === 'string'
62
+ ? 'Pipe ' + port
63
+ : 'Port ' + port;
64
+
65
+ // handle specific listen errors with friendly messages
66
+ switch (error.code) {
67
+ case 'EACCES':
68
+ console.error(bind + ' requires elevated privileges');
69
+ process.exit(1);
70
+ break;
71
+ case 'EADDRINUSE':
72
+ console.error(bind + ' is already in use');
73
+ process.exit(1);
74
+ break;
75
+ default:
76
+ throw error;
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Event listener for HTTP server "listening" event.
82
+ */
83
+
84
+ function onListening() {
85
+ var addr = server.address();
86
+ var bind = typeof addr === 'string'
87
+ ? 'pipe ' + addr
88
+ : 'port ' + addr.port;
89
+ debug('Listening on ' + bind);
90
+ }
@@ -0,0 +1,17 @@
1
+ // middlewares/error-handler.js
2
+
3
+ module.exports = (err, req, res, next) => {
4
+ // set locals, only providing error in development
5
+ res.locals.message = err.message;
6
+ res.locals.error = req.app.get('env') === 'development' ? err : {};
7
+
8
+ // render the error page
9
+ res.status(err.status || 500);
10
+
11
+ // if you want to use json, you can use res.json instead of res.render
12
+ // res.json({
13
+ // status: false,
14
+ // message: err.message
15
+ // });
16
+ res.render('error');
17
+ };
@@ -0,0 +1,48 @@
1
+ import path from 'path';
2
+ import { fileURLToPath } from 'url';
3
+
4
+ import express from 'express';
5
+ <% Object.keys(modules).sort().forEach(function (variable) { -%>
6
+ import <%- variable %> from '<%- modules[variable] %>';
7
+ <% }); -%>
8
+
9
+ <% if (view) { -%>
10
+ import createError from 'http-errors';
11
+ import errorHandler from './middlewares/error-handler.js';
12
+ <% } -%>
13
+
14
+ // environment variables
15
+ import 'dotenv/config';
16
+ import routes from './config/routes.js';
17
+
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
+
20
+ const app = express();
21
+
22
+ <% if (view) { -%>
23
+ // view engine setup
24
+ <% if (view.render) { -%>
25
+ app.engine('<%- view.engine %>', <%- view.render %>);
26
+ <% } -%>
27
+ app.set('views', path.join(__dirname, 'views'));
28
+ app.set('view engine', '<%- view.engine %>');
29
+
30
+ <% } -%>
31
+ <% uses.forEach(function (use) { -%>
32
+ app.use(<%- use %>);
33
+ <% }); -%>
34
+
35
+ // routes
36
+ app.use(routes);
37
+
38
+ <% if (view) { -%>
39
+ // catch 404 and forward to error handler
40
+ app.use((req, res, next) => {
41
+ next(createError(404));
42
+ });
43
+
44
+ // error handler
45
+ app.use(errorHandler);
46
+
47
+ <% } -%>
48
+ export default app;
@@ -0,0 +1,10 @@
1
+ import express from 'express';
2
+ import indexRouter from '../routes/index.js';
3
+ import usersRouter from '../routes/users.js';
4
+
5
+ const router = express.Router();
6
+
7
+ router.use('/', indexRouter);
8
+ router.use('/users', usersRouter);
9
+
10
+ export default router;
@@ -0,0 +1,11 @@
1
+ import express from 'express';
2
+ const router = express.Router();
3
+
4
+ /* GET home page. */
5
+ router.get('/', (req, res, next) => {
6
+ // if you want to use json, you can use res.json instead of res.render
7
+ // res.json({ title: 'Express' });
8
+ res.render('index', { title: 'Express' });
9
+ });
10
+
11
+ export default router;
@@ -0,0 +1,9 @@
1
+ import express from 'express';
2
+ const router = express.Router();
3
+
4
+ /* GET users listing. */
5
+ router.get('/', (req, res, next) => {
6
+ res.send('respond with a resource');
7
+ });
8
+
9
+ export default router;
@@ -0,0 +1,92 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Module dependencies.
5
+ */
6
+
7
+ import http from 'http';
8
+
9
+ import app from '../app.js';
10
+ import debugFunction from 'debug';
11
+ const debug = debugFunction('<%- name %>:server');
12
+
13
+ /**
14
+ * Get port from environment and store in Express.
15
+ */
16
+
17
+ const port = normalizePort(process.env.PORT || '3000');
18
+ app.set('port', port);
19
+
20
+ /**
21
+ * Create HTTP server.
22
+ */
23
+
24
+ const server = http.createServer(app);
25
+
26
+ /**
27
+ * Listen on provided port, on all network interfaces.
28
+ */
29
+
30
+ server.listen(port);
31
+ server.on('error', onError);
32
+ server.on('listening', onListening);
33
+
34
+ /**
35
+ * Normalize a port into a number, string, or false.
36
+ */
37
+
38
+ function normalizePort(val) {
39
+ const port = parseInt(val, 10);
40
+
41
+ if (isNaN(port)) {
42
+ // named pipe
43
+ return val;
44
+ }
45
+
46
+ if (port >= 0) {
47
+ // port number
48
+ return port;
49
+ }
50
+
51
+ return false;
52
+ }
53
+
54
+ /**
55
+ * Event listener for HTTP server "error" event.
56
+ */
57
+
58
+ function onError(error) {
59
+ if (error.syscall !== 'listen') {
60
+ throw error;
61
+ }
62
+
63
+ const bind = typeof port === 'string'
64
+ ? 'Pipe ' + port
65
+ : 'Port ' + port;
66
+
67
+ // handle specific listen errors with friendly messages
68
+ switch (error.code) {
69
+ case 'EACCES':
70
+ console.error(bind + ' requires elevated privileges');
71
+ process.exit(1);
72
+ break;
73
+ case 'EADDRINUSE':
74
+ console.error(bind + ' is already in use');
75
+ process.exit(1);
76
+ break;
77
+ default:
78
+ throw error;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Event listener for HTTP server "listening" event.
84
+ */
85
+
86
+ function onListening() {
87
+ const addr = server.address();
88
+ const bind = typeof addr === 'string'
89
+ ? 'pipe ' + addr
90
+ : 'port ' + addr.port;
91
+ debug('Listening on ' + bind);
92
+ }
@@ -0,0 +1,14 @@
1
+ // This is your Prisma schema file,
2
+ // learn more about it in the docs: https://pris.ly/d/prisma-schema
3
+
4
+ // Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?
5
+ // Try Prisma Accelerate: https://pris.ly/cli/accelerate-init
6
+
7
+ generator client {
8
+ provider = "prisma-client-js"
9
+ }
10
+
11
+ datasource db {
12
+ provider = "mysql"
13
+ url = env("DATABASE_URL")
14
+ }
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{title}</title>
5
+ <link rel='stylesheet' href='/stylesheets/style.css' />
6
+ </head>
7
+ <body>
8
+ <h1>{message}</h1>
9
+ <h2>{error.status}</h2>
10
+ <pre>{error.stack}</pre>
11
+ </body>
12
+ </html>
@@ -0,0 +1,3 @@
1
+ <h1><%= message %></h1>
2
+ <h2><%= error.status %></h2>
3
+ <pre><%= error.stack %></pre>
@@ -0,0 +1,3 @@
1
+ <h1>{{message}}</h1>
2
+ <h2>{{error.status}}</h2>
3
+ <pre>{{error.stack}}</pre>
@@ -0,0 +1,3 @@
1
+ <h1>{{ message }}</h1>
2
+ <h2>{{ error.status }}</h2>
3
+ <pre>{{ error.stack }}</pre>
@@ -0,0 +1,6 @@
1
+ extends layout
2
+
3
+ block content
4
+ h1= message
5
+ h2= error.status
6
+ pre #{error.stack}
@@ -0,0 +1,6 @@
1
+ extends layout
2
+
3
+ block content
4
+ h1= message
5
+ h2= error.status
6
+ pre #{error.stack}
@@ -0,0 +1,7 @@
1
+ {% extends 'layout.twig' %}
2
+
3
+ {% block body %}
4
+ <h1>{{message}}</h1>
5
+ <h2>{{error.status}}</h2>
6
+ <pre>{{error.stack}}</pre>
7
+ {% endblock %}
@@ -0,0 +1,7 @@
1
+ @html.extend('layout', function(model) {
2
+ @html.block('content', function(model) {
3
+ <h1>@model.message</h1>
4
+ <h2>@model.error.status</h2>
5
+ <pre>@model.error.stack</pre>
6
+ })
7
+ })
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{title}</title>
5
+ <link rel='stylesheet' href='/stylesheets/style.css' />
6
+ </head>
7
+ <body>
8
+ <h1>{title}</h1>
9
+ <p>Welcome to {title}</p>
10
+ </body>
11
+ </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= title %></title>
5
+ <link rel='stylesheet' href='/stylesheets/style.css' />
6
+ </head>
7
+ <body>
8
+ <h1><%= title %></h1>
9
+ <p>Welcome to <%= title %></p>
10
+ </body>
11
+ </html>
@@ -0,0 +1,2 @@
1
+ <h1>{{title}}</h1>
2
+ <p>Welcome to {{title}}</p>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ title }}</title>
5
+ <link rel='stylesheet' href='/stylesheets/style.css' />
6
+ </head>
7
+ <body>
8
+ <h1>{{ title }}</h1>
9
+ <p>Welcome to {{ title }}</p>
10
+ </body>
11
+ </html>
@@ -0,0 +1,5 @@
1
+ extends layout
2
+
3
+ block content
4
+ h1= title
5
+ p Welcome to #{title}
@@ -0,0 +1,5 @@
1
+ extends layout
2
+
3
+ block content
4
+ h1= title
5
+ p Welcome to #{title}
@@ -0,0 +1,6 @@
1
+ {% extends 'layout.twig' %}
2
+
3
+ {% block body %}
4
+ <h1>{{title}}</h1>
5
+ <p>Welcome to {{title}}</p>
6
+ {% endblock %}
@@ -0,0 +1,6 @@
1
+ @html.extend('layout', function(model) {
2
+ @html.block('content', function(model) {
3
+ <h1>@model.title</h1>
4
+ <p>Welcome to @model.title</p>
5
+ })
6
+ })
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{title}}</title>
5
+ <link rel='stylesheet' href='/stylesheets/style.css' />
6
+ </head>
7
+ <body>
8
+ {{{body}}}
9
+ </body>
10
+ </html>
@@ -0,0 +1,7 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title= title
5
+ link(rel='stylesheet', href='/stylesheets/style.css')
6
+ body
7
+ block content
@@ -0,0 +1,7 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title= title
5
+ link(rel='stylesheet', href='/stylesheets/style.css')
6
+ body
7
+ block content
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>{{ title }}</title>
5
+ <link rel='stylesheet' href='/stylesheets/style.css' />
6
+ </head>
7
+ <body>
8
+ {% block body %}{% endblock %}
9
+ </body>
10
+ </html>
@@ -0,0 +1,11 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta>
5
+ <title>@model.title</title>
6
+ <link rel='stylesheet' href='/stylesheets/style.css' />
7
+ </head>
8
+ <body>
9
+ @html.block('content')
10
+ </body>
11
+ </html>