change gitignore. change server.js
This commit is contained in:
committed by
Daniel Hutzel
parent
00474edffe
commit
ee63541845
4
media-store/.gitignore
vendored
4
media-store/.gitignore
vendored
@@ -7,13 +7,11 @@ gen/
|
|||||||
node_modules/
|
node_modules/
|
||||||
target/
|
target/
|
||||||
package-lock.json
|
package-lock.json
|
||||||
|
app/
|
||||||
|
|
||||||
# html5Deployer
|
# html5Deployer
|
||||||
deployers/html5Deployer/resources/app/
|
deployers/html5Deployer/resources/app/
|
||||||
|
|
||||||
# app
|
|
||||||
app/
|
|
||||||
|
|
||||||
# Web IDE, App Studio
|
# Web IDE, App Studio
|
||||||
.che/
|
.che/
|
||||||
.gen/
|
.gen/
|
||||||
|
|||||||
23
media-store/app/.gitignore
vendored
Normal file
23
media-store/app/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
13
media-store/app/.vscode/launch.json
vendored
Normal file
13
media-store/app/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Chrome",
|
||||||
|
"type": "chrome",
|
||||||
|
"request": "launch",
|
||||||
|
"url": "http://localhost:3000",
|
||||||
|
"webRoot": "${workspaceRoot}/src"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -16,6 +16,8 @@ build-parameters:
|
|||||||
commands:
|
commands:
|
||||||
- npm install
|
- npm install
|
||||||
- npx @sap/cds-dk build
|
- npx @sap/cds-dk build
|
||||||
|
- npm --prefix ./app-src install ./app-src
|
||||||
|
- npm run build --prefix ./app-src #This line runs the build script
|
||||||
|
|
||||||
modules:
|
modules:
|
||||||
# --------------------- SERVER MODULE ------------------------
|
# --------------------- SERVER MODULE ------------------------
|
||||||
@@ -48,7 +50,7 @@ modules:
|
|||||||
- name: media-store-hmtl5-deployer
|
- name: media-store-hmtl5-deployer
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
type: com.sap.html5.application-content
|
type: com.sap.html5.application-content
|
||||||
path: html5Deployer
|
path: deployers/html5Deployer
|
||||||
requires:
|
requires:
|
||||||
- name: media-store-html5-host
|
- name: media-store-html5-host
|
||||||
build-parameters:
|
build-parameters:
|
||||||
@@ -65,13 +67,13 @@ modules:
|
|||||||
path: app
|
path: app
|
||||||
build-parameters:
|
build-parameters:
|
||||||
supported-platforms: []
|
supported-platforms: []
|
||||||
build-result: build
|
build-result: /
|
||||||
|
|
||||||
# --------------------- APPROUTER MODULE ---------------------
|
# --------------------- APPROUTER MODULE ---------------------
|
||||||
- name: media-store-approuter
|
- name: media-store-approuter
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
type: approuter.nodejs
|
type: approuter.nodejs
|
||||||
path: approuter
|
path: deployers/approuter
|
||||||
requires:
|
requires:
|
||||||
- name: media-store-html5-runtime
|
- name: media-store-html5-runtime
|
||||||
- name: media-store-xsuaa
|
- name: media-store-xsuaa
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
const cds = require("@sap/cds");
|
const cds = require("@sap/cds");
|
||||||
|
const {
|
||||||
|
getDurationInMilliseconds,
|
||||||
|
getFormattedDateTime,
|
||||||
|
} = require("./util/helpers");
|
||||||
|
|
||||||
// handle bootstrapping events...
|
// handle bootstrapping events...
|
||||||
cds.on("bootstrap", (app) => {
|
cds.on("bootstrap", (app) => {
|
||||||
@@ -28,13 +32,26 @@ cds.on("bootstrap", (app) => {
|
|||||||
cds.on("served", async ({ db, messaging, ...servedServices }) => {
|
cds.on("served", async ({ db, messaging, ...servedServices }) => {
|
||||||
// add logging current user before any request
|
// add logging current user before any request
|
||||||
for (let i in servedServices) {
|
for (let i in servedServices) {
|
||||||
servedServices[i].prepend((srv) =>
|
servedServices[i].prepend((srv) => {
|
||||||
srv.before("*", (req) => {
|
srv.on("*", async (req, next) => {
|
||||||
|
const method = req._.req.method;
|
||||||
|
const url = req._.req.url;
|
||||||
|
const start = process.hrtime();
|
||||||
|
|
||||||
if (req.user) {
|
if (req.user) {
|
||||||
console.log("[USER]:", req.user.id, req.user.attr, req.user._roles);
|
console.log("[USER]:", req.user.id, req.user.attr, req.user._roles);
|
||||||
}
|
}
|
||||||
})
|
const result = await next();
|
||||||
);
|
|
||||||
|
const status = req._.res.statusCode;
|
||||||
|
const currentDateTime = getFormattedDateTime();
|
||||||
|
const durationInMilliseconds = getDurationInMilliseconds(start);
|
||||||
|
const log = `[${currentDateTime}] ${durationInMilliseconds.toLocaleString()} ms ${method}:${url} status: ${status} `;
|
||||||
|
console.log(log);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ const jwt = require("jsonwebtoken");
|
|||||||
const bcrypt = require("bcryptjs");
|
const bcrypt = require("bcryptjs");
|
||||||
|
|
||||||
const { ACCESS_TOKEN_SECRET, REFRESH_TOKEN_SECRET } = cds.env;
|
const { ACCESS_TOKEN_SECRET, REFRESH_TOKEN_SECRET } = cds.env;
|
||||||
|
|
||||||
const ACCESS_TOKEN_EXP_IN = "10m";
|
const ACCESS_TOKEN_EXP_IN = "10m";
|
||||||
const REFRESH_TOKEN_EXPIRES_IN = "20m";
|
const REFRESH_TOKEN_EXPIRES_IN = "20m";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user