Tag: 速递

如何在Angular 4 / expressJS服务器上直接运行项目(没有webpack)

现在我执行'build'和exec'ts-node ./src/index.ts': //////////index.ts import * as express from 'express'; import { join } from 'path'; import { json, urlencoded }from 'body-parser'; import BaseRoutes = require("./backend/services/newService"); var app : any = express(); app.use(express.static(join(__dirname + '/../dist/'))); app.use(json()); app.use(urlencoded({extended: true})); app.use('/api', new BaseRoutes().routes); app.get('*', function(req, res, next) { res.sendFile(join(__dirname + '/../index.html')); }); app.listen(3000); 所有的工作都很好,但是如何只运行expressJS服务器,只用原始文件编译项目(没有webpack)。 在推推的情况下我编译项目只压缩/ dist /文件,否则我想与原始文件工作 varibale […]

为什么我的jwt令牌在背面而不是在前面返回null

我正在尝试向我的mLab数据库发出GET请求。 我传递一个带有请求的JWT令牌,并将其logging在客户端和服务器上。 它在客户端上正确读取,但在服务器上显示为空。 任何帮助将非常感激。 我正在使用Node.js和Angular。 我对此很新,所以如果错误是显而易见的,我就提前道歉。 这里是服务器的GET路由: router.get('/', (req, res, next) => { var decoded = jwt.decode(req.query.token); console.log(decoded); console.log('employees'); if(decoded) { return Company.find({_id: decoded._id}) .populate('user', 'firstName') .exec(function(err, company) { if (err) { return res.status(500).json({ title: 'An error occurred', error: err }); } res.status(200).json({ message: 'Success', obj: company }); }); } else { return res.status(401).json({ title: […]

安装Angular 2 Universal

更新: 我正在尝试使用本指南来安装Angular 2 Universal,但是当我运行以下命令时,出现一些错误。 这里是命令: typings install node express body-parser serve-static dexpress-serve-static-core mime –global –save 而错误是: C:\Users\user\Desktop\myApp>typings install node express body-parser serve-static dexpress-serve-static-core mime –global –save typings INFO globaldependencies "express" lists global dependencies on "node" that must be installed manually typings INFO globaldependencies "serve-static" lists global dependencies on "node" that must be installed manually typings […]