express-sweet-generator 2.0.21 → 2.0.22
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/package.json +1 -1
- package/templates/cjs/app.js +2 -2
- package/templates/cjs/models/BookModel.js +2 -2
- package/templates/cjs/models/CommentModel.js +2 -2
- package/templates/cjs/models/ProfileModel.js +2 -2
- package/templates/cjs/models/UserModel.js +2 -2
- package/templates/cjs/package.json.ejs +1 -1
- package/templates/cjs/routes/api/profile.js +1 -1
- package/templates/cjs/routes/api/users.js +3 -3
- package/templates/esm/app.js +2 -2
- package/templates/esm/models/BookModel.js +2 -2
- package/templates/esm/models/CommentModel.js +2 -2
- package/templates/esm/models/ProfileModel.js +2 -2
- package/templates/esm/models/UserModel.js +2 -2
- package/templates/esm/package.json.ejs +1 -1
- package/templates/esm/routes/api/profile.js +1 -1
- package/templates/esm/routes/api/users.js +3 -3
package/package.json
CHANGED
package/templates/cjs/app.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
|
-
const
|
|
2
|
+
const expx = require('express-sweet');
|
|
3
3
|
|
|
4
4
|
// Creates and configures an ExpressJS web server.
|
|
5
5
|
const app = express();
|
|
6
6
|
|
|
7
7
|
// Mount the extension.
|
|
8
|
-
|
|
8
|
+
expx.mount(app);
|
|
9
9
|
|
|
10
10
|
module.exports = app;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const
|
|
1
|
+
const expx = require('express-sweet');
|
|
2
2
|
const {Media} = require('nodejs-shared');
|
|
3
3
|
const NotFoundError = require('../errors/NotFoundError');
|
|
4
4
|
|
|
5
|
-
module.exports = class extends
|
|
5
|
+
module.exports = class extends expx.database.Model {
|
|
6
6
|
static get table() {
|
|
7
7
|
return 'user';
|
|
8
8
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
|
-
// const
|
|
2
|
+
// const expx = require('express-sweet');
|
|
3
3
|
const {body} = require('express-validator');
|
|
4
4
|
const UserModel = require('../../models/UserModel');
|
|
5
5
|
const NotFoundError = require('../../errors/NotFoundError');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const express = require('express');
|
|
2
|
-
const
|
|
2
|
+
const expx = require('express-sweet');
|
|
3
3
|
const {query, body} = require('express-validator');
|
|
4
4
|
const UserModel = require('../../models/UserModel');
|
|
5
5
|
const NotFoundError = require('../../errors/NotFoundError');
|
|
@@ -13,12 +13,12 @@ router.post('/login', [
|
|
|
13
13
|
body('password').trim().not().isEmpty(),
|
|
14
14
|
checkValidationResult,
|
|
15
15
|
], async (req, res, next) => {
|
|
16
|
-
const isAuthenticated = await
|
|
16
|
+
const isAuthenticated = await expx.services.Authentication.authenticate(req, res, next);
|
|
17
17
|
res.json(isAuthenticated);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
router.get('/logout', (req, res) => {
|
|
21
|
-
|
|
21
|
+
expx.services.Authentication.logout(req);
|
|
22
22
|
res.redirect('/');
|
|
23
23
|
});
|
|
24
24
|
|
package/templates/esm/app.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import express from 'express'
|
|
2
|
-
import * as
|
|
2
|
+
import * as expx from 'express-sweet';
|
|
3
3
|
|
|
4
4
|
// Creates and configures an ExpressJS web server.
|
|
5
5
|
const app = express();
|
|
6
6
|
|
|
7
7
|
// Mount the extension.
|
|
8
|
-
|
|
8
|
+
expx.mount(app);
|
|
9
9
|
|
|
10
10
|
export default app;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as expx from 'express-sweet';
|
|
2
2
|
import UserModel from './UserModel.js';
|
|
3
3
|
|
|
4
|
-
export default class extends
|
|
4
|
+
export default class extends expx.database.Model {
|
|
5
5
|
static get table() {
|
|
6
6
|
return 'profile';
|
|
7
7
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as expx from 'express-sweet';
|
|
2
2
|
import {Media} from 'nodejs-shared';
|
|
3
3
|
import NotFoundError from '../errors/NotFoundError.js';
|
|
4
4
|
import ProfileModel from './ProfileModel.js';
|
|
5
5
|
import CommentModel from './CommentModel.js';
|
|
6
6
|
import BookModel from './BookModel.js';
|
|
7
7
|
|
|
8
|
-
export default class extends
|
|
8
|
+
export default class extends expx.database.Model {
|
|
9
9
|
static get table() {
|
|
10
10
|
return 'user';
|
|
11
11
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as expx from 'express-sweet';
|
|
2
2
|
import {Router} from 'express';
|
|
3
3
|
import {query, body} from 'express-validator';
|
|
4
4
|
import UserModel from '../../models/UserModel.js';
|
|
@@ -13,12 +13,12 @@ router.post('/login', [
|
|
|
13
13
|
body('password').trim().not().isEmpty(),
|
|
14
14
|
checkValidationResult,
|
|
15
15
|
], async (req, res, next) => {
|
|
16
|
-
const isAuthenticated = await
|
|
16
|
+
const isAuthenticated = await expx.services.Authentication.authenticate(req, res, next);
|
|
17
17
|
res.json(isAuthenticated);
|
|
18
18
|
});
|
|
19
19
|
|
|
20
20
|
router.get('/logout', (req, res) => {
|
|
21
|
-
|
|
21
|
+
expx.services.Authentication.logout(req);
|
|
22
22
|
res.redirect('/');
|
|
23
23
|
});
|
|
24
24
|
|