Tag: expression

为什么翡翠文件不想加载CSS

我正在尝试使用Node.js将login/注册function添加到我的网站,所以它将会保存用户的进度,因为他将继续使用网站。 但是这个问题不是关于node.js代码,而是关于.jade的。 我不是很熟悉玉,我只是不明白为什么它不想加载我的CSS文件。 和快速的问题:是否有必要使用jade,当你使用一个nodejs,或者有一种方法来使用html而不是节点? layout.jade doctype html head meta(charset='utf-8') meta(name='viewport', content='width=device-width, initial-scale=1, shrink- to-fit=no') meta(name='description', content='') meta(name='author', content='') link(rel='icon', href='favicon.ico') title Job Finder // Bootstrap core CSS link(href='public/stylesheets/bootstrap.min.css', rel='stylesheet') // Custom styles for this template link(href='public/stylesheets/album.css', rel='stylesheet') link(href='public/stylesheets/cover.css', rel='stylesheet') link(href='public/stylesheets/path.css', rel='stylesheet') #navbarHeader.collapse.bg-dark .container .row .col-sm-8.py-4 h4.text-white About Us p.text-muted text .col-sm-4.py-4 h4.text-white Support Us ul.list-unstyled […]

Keycloak:authZ和nodeJS

我正在尝试使用keycloak授权机制来保护REST API。 我的API在NodeJS中用express。 说我有这个API: http://www.example.com/api/v1/houses 端点支持GET / POST / PUT / DELETE。 一个房子有一个名字和一个主人: { name: 'myhouse', owner: 'smith' } 每个人都可以看房子。 你也可以创build房屋,并自动成为所有者。 只有业主可以删除一个房子。 这和photoz例子很相似。 使用Keycloak连接仅在bearer-only模式下使用nodeJS express: router.get('/houses*', keycloakProtect(), myHandler) 但是这只提供了authentication,而不是授权。 基本上它只是检查你提供了正确的标记。 KeycloakProtect仅提供基于angular色名称的基本授权机制。 但是,我想充分利用客户端授权(包括资源,范围和策略)…是否有任何NodeJS支持? 如果不是,如何使用Keycloak API呢?

笑npm脚本的正则expression式

我想执行2个不同的testing环境, 一个用于integration tests ,另一个用于unit tests 。 文件夹结构是这样的: __tests__/ut/p/a/t/h/file.test.ts __tests__/it/p/a/t/h/file.test.ts 我拿出了这些正则expression式: (__tests__/ut/.*\.test)\.(tsx?|ts?)$ (__tests__/it/.*\.test)\.(tsx?|ts?)$ 我的脚本如下所示: "test:ut": "jest \"(__tests__/ut/.*\\.test)\\.(tsx?|ts?)$\"", "test:it": "jest \"(__tests__/it/.*\\.test)\\.(tsx?|ts?)$\"", 但是当我运行yarn test:ut我得到: yarn run v1.3.2 $ jest "(__tests__/ut/.*\.test)\.(tsx?|ts?)$" No tests found In /home/dev/sample 20 files checked. testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) – 0 matches testPathIgnorePatterns: /node_modules/ – 20 matches Pattern: (__tests__/ut/.*\.test)\.(tsx?|ts?)$ – 0 matches Done in 0.49s. 虽然,如果我在jsonconfiguration文件中使用相同的模式,它工作。 我想我是如何执行这个jest […]

search查询angular度4restAPI

我遵循的教程工作: https : //alligator.io/angular/real-time-search-angular-rxjs/我需要改变我的应用程序的一些信息,但无法正常工作。 按照代码:组件: export class SearchComponent implements OnInit { articlePosts; results: Object; searchTerm$ = new Subject<string>(); constructor( private searchService: SearchService, private authService: AuthService ) { this.searchService.search(this.searchTerm$) .subscribe(results => { this.articlePosts = results.articles; }); } } 服务: export class SearchService { options; domain = this.authService.domain; queryUrl: string = '?search='; constructor( private authService: AuthService, private […]

使NodeJSfunction同步? 在查询数据库之前发送json响应

我正在使用nodejs作为后端语言进行login/注册android应用程序UI。 发生什么事情是,每当我点击注册button,它发送json响应之前查询数据库(select语句来检查是否存在用户名)导致android应用程序得到错误的响应,导致我点击button两次注册正确响应。 例如,让我们说他们是一个名为testing在数据库中的用户名,我尝试使用用户名testing注册,它会告诉我,用户名已被采取,如果擦除testing,并input让说'BOB'不存在数据库它仍然说,用户名已被采取,即使它不是,但当我再次单击注册button它将注册用户。 我假设这是因为它是asynchronous(它发送json响应,而查询数据库之前或之前)。 我怎样才能使这个同步,或有另一种方法来解决这个问题? 服务器文件: var express = require('express'); var app = express(); var bodyParser = require('body-parser'); var mysql = require('mysql'); //connection var con = mysql.createConnection({ host: "localhost", user: "root", password: "password", database : "androidtest" }); //use json app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); //declare variables to hold values entered by the user var name; […]

PM2端口号表示应用程序

ecosystem.config.js module.exports = { /** * Application configuration section * http://pm2.keymetrics.io/docs/usage/application-declaration/ */ apps : [ // First application { name : 'cms_stage', script : 'www', env: { COMMON_VARIABLE: 'true', PORT: 3001, NODE_ENV: 'staging' } } ] } 我有一个快速的应用程序,当我开始与PORT=3001 node www ,它的工作原理。 但是与pm2上面的configuration它不。 pm2节目开始,但它不听3001 我尝试运行PORT=3001 pm2 start cms_stage , pm2 start cms_stage和PORT=3001 pm2 start cms_stage pm2 […]

Api调用MEAN4 +

所以我在一个平均的堆栈应用程序工作,但我只是没有得到我的api的权利..唯一的作品是GET! 我的post似乎并没有工作,我想我的语法错了,但我只是没有在互联网上find正确的。 //GET router.get('/employees', (req, res) => { connection((db) => { db.collection('employees') .find() .toArray() .then((employees) => { response.data = employees; res.json(response); }) .catch((err) => { sendError(err, res); }); }); }); // POST router.post('/employees', (req, res) => { const employees = { name: req.body.name, age: req.body.age , wage: req.body.wage , place: req.body.place }; db.collection('employees').insert(employees, (err, result) […]

firebase表示云function错误

我一直想疯狂得到这个firebase的http函数与Cors工作。 基本上,我在本地服务pipe理员SDK来validation某个用户令牌是否具有pipe理权限。 令牌通过get请求作为url中的参数发送。 我目前正在得到一个404错误,并且在请求的资源上出现“No”Access-Control-Allow-Origin“头”错误。 我已经尝试重新安排我的代码一堆不同的方式,包括firebase如何在文档中做到这一点,但总是最终得到的Cors随着404或500错误。 const functions = require('firebase-functions'); const admin = require('firebase-admin'); const cors = require('cors'); const express = require('express'); const corsOptions = { origin: '*', allowedHeaders: ['Content-Type', 'Authorization', 'Content-Length', 'X-Requested-With', 'Accept'], methods: ['GET', 'PUT', 'POST', 'DELETE', 'OPTIONS'], optionsSuccessStatus: 200 }; let app = express() app.use(cors); app.get('/AdminSignIn/:token',(req, res) => { cors(corsOptions,(req,res) =>{ admin.auth.verifyIdToken(req.params.token).then((claims) => […]

Express Passport.js不保留会话中的用户对象

我有一个运行在端口3000上的Express应用程序。前端运行在端口80上,所以这是一个CORS应用程序。 用户存储在SQL服务器数据库中。 我使用护照作为本地策略的authentication方法,以及快速会话中间件。 该应用程序是一个单页面应用程序,发送到服务器的所有请求都通过ajax完成。 用户在页面上login并且发送证书,并且如果validation成功,则用户ID以及用户名和FullNmae应该被保持到会话。 我有很多这样的错误:最重要的是,login后,快递保存使用护照的用户名和其他数据到一个新的会话,并返回一个HTML片段,以取代页面上的身体标记。 但是,为了testing用户对象是否存在,我调用/ create-user路由,它说用户对象不在那里。 此外,新的会话开始于每个请求(我检查日志,并看到每次显示不同的会话ID)。 不仅如此,在某一时刻,我能够在浏览器中看到会话cookie,但是我再也看不到它了。 我试图回到我可以看到cookie的地步,但仍然没有出现! 我已经把我的头几个小时,不知道为什么deserializeUser没有被调用,为什么数据不被持久。 我哪里错了? 注意:一些明显的代码省略(app.listen(),require语句等) /* —— CONFIGURATIONS —— */ const app = express(); const mssqlConfig = JSON.parse(fs.readFileSync("mssql-config.json", "utf8")); passport.use(new LocalStrategy( function loginAuthentication(username, password, done) { let connPool = new mssql.ConnectionPool(mssqlConfig); connPool.connect(error => { if (error) {console.log(error); return done(error);} ps = new mssql.PreparedStatement(connPool); ps.input('username', mssql.NVarChar(20)); ps.input('password', […]

(Angular4 / MEAN)将请求发送到空本体的本地API结果

我试图发布数据到一个项目的API,例如: "data": { "title": "stack", "notes": "asdsad", "time": "19:02", "meridian": "PM", "type": "Education", "_id": "5a2f02d3bba3640337bc92c9", "days": { "Monday": true, "Tuesday": false, "Wednesday": false, "Thursday": false, "Friday": false, "Saturday": false, "Sunday": false } } 但是,使用HttpClient发布数据时 this.http.post("http://localhost:3000/api/items", JSON.stringify(item)) .subscribe( (val) => { console.log("POST call successful value returned in body", val); }, response => { console.log("POST call in […]