克劳迪娅创造
跟随
this turoial
.aws/证书
文件。
claudia——source dist generate serverless express proxy——express模块应用
我的
'use strict'
const awsServerlessExpress = require('aws-serverless-express')
const app = require('./app')
const binaryMimeTypes = [
'application/octet-stream',
'font/eot',
'font/opentype',
'font/otf',
'image/jpeg',
'image/png',
'image/svg+xml'
]
const server = awsServerlessExpress.createServer(app, null, binaryMimeTypes);
exports.handler = (event, context) => awsServerlessExpress.proxy(server, event, context)
然后我尝试在AWS上部署lambda函数:
但我犯了个错误:
验证包类型错误:“listener”参数必须是函数
在addListener(events.js:239:11)
位于Server.addListener(events.js:297:10)
在新服务器上(_http_Server.js:269:10)
在Object.createServer上(http.js:34:10)
在Object.createServer上(/tmp/IiRPif/my-project-1.0.0-1Yh6Wb/package/node廑modules/aws serverless express/index.js:155:25)
在模块上编译(Module.js:652:30)
在Object.Module.\u extensions..js处(Module.js:663:10)
在Module.load处(Module.js:565:32)
在Function.Module.加载(Module.js:497:3)
at Module.require(模块js:596:17)
at要求(内部/模块.js:11:18)
在initEnvVarsFromOptions.then.then.then.then.then.then.dir(/usr/local/lib/node_modules/claudia/src/commands/create.js:342:10)
at不需要./lambda,请在干净安装之后。检查你的依赖关系。
我在这里做错什么了?
包.json
{
"name": "...",
"version": "1.0.0",
"scripts": {
"build": "tsc -p tsconfig.json & cp \"package.json\" \"dist/package.json\"
},
"repository": {
"type": "git",
"url": "..."
},
"homepage": "...",
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.3",
"mongoose": "^5.2.7",
"nodemon": "^1.18.3"
},
"devDependencies": {
"typescript": "^3.0.1"
}
}
我的
import * as express from "express";
import * as bodyParser from "body-parser";
import * as mongoose from "mongoose";
import { Routes } from "./routes/routes";
class App {
public app: express.Application;
public routes: Routes = new Routes();
constructor() {
this.app = express();
// Parser setup
this.app.use(bodyParser.json());
this.app.use(bodyParser.urlencoded({ extended: true }));
this.routes.routes(this.app);
}
}
exports.default = new App().app;