Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`
}
// we're exporting the handler-function as default, must match the sls-config!
//export default (assetsDir, resolvedAssetsPath) => serverless(createServer(assetsDir, resolvedAssetsPath));
/*
const serverIndexPath = path.join(serverPath, "index.js");
fs.writeFileSync(serverIndexPath, `const lib = require ('./server');
const server = lib.default('${ssrConfig.assetsPath}', '${resolveAssetsPath(ssrConfig)}');
exports.default = server;*/
// these variables are replaced during compilation
export default serverless(createServer(__ASSETS_PATH__, __RESOLVED_ASSETS_PATH__, __ISOMORPHIC_ID__, __ISOFFLINE__));
} else if (service.method.toUpperCase() == "DELETE") {
app.delete(service.path, ...unpackMiddlewares(service.middlewares));
}
return service;
});
return app;
};
// these variables are replaced during compilation
export default serverless(createServer(__SERVICEORIENTED_ID__, __ISOFFLINE__));
// index.js
import serverless from 'serverless-http'
import express from 'express'
import wiki from './wiki'
const app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use('/wiki', wiki)
module.exports.handler = serverless(app)
import serverless from 'serverless-http';
import express from 'express';
import Todo from 'models/todo';
export const handler = async (req, res) => {
const result = await Todo.get({
id: req.params.id,
});
res.json(result);
};
export const app = express().use('/todos/:id', handler);
export default serverless(app);
import serverless from 'serverless-http'
import express from 'express'
const app = express()
app.get('/yo', (req, res) => {
res.send('Hello World!')
})
exports.handler = serverless(app)
import Todo from 'models/todo';
export const handler = async (req, res) => {
const result = await Todo.update(
{
id: req.params.id,
},
req.body,
);
res.json(result);
};
export const app = express().use('/todos/:id', [bodyParser.json(), handler]);
export default serverless(app);
import { APIGatewayProxyHandler } from 'aws-lambda';
import express from 'express';
import serverlessHttp from 'serverless-http';
import { AppConfig } from './app/app.config';
import fs from 'fs';
import { CloudApp } from './app';
import { Swagger } from './specifications/swagger/swagger';
import { SwaggerConfig } from './specifications/swagger/swagger.config';
import { S3StorageAdapter } from './storage/s3.storage';
import { CloudEnvironment } from './environment/cloud.environment';
const server = express();
const sls = serverlessHttp(server);
const defaultConfig = new AppConfig();
const config = JSON.parse(fs.readFileSync('./config/appconfig.json', 'UTF-8'));
const appConfig = AppConfig.merge(defaultConfig, config);
const environment = new CloudEnvironment();
const swagger = new Swagger(
server,
new SwaggerConfig(appConfig.readOnly, appConfig.enableApiKeyAuth),
environment.basePath
);
const core = new CloudApp(
appConfig,
server,
new S3StorageAdapter(environment.s3Bucket, environment.s3File),
swagger
);
(async () => {
import serverless from "serverless-http";
import app from "./graphql";
export const handler = serverless(app());
},
},
introspection: true,
});
const app = express();
app.use(compression({ threshold: 0 }));
app.use(cors());
if (isDevelopment) {
app.use(morgan('dev'));
}
server.applyMiddleware({ app });
const handler = serverless(app);
export { handler };
import Todo from 'models/todo';
const handler = async (req, res) => {
const { text } = req.body;
const result = await Todo.create({
id: uuid.v1(),
text,
checked: false,
});
res.json(result);
};
export const app = express().use([bodyParser.json(), handler]);
export default serverless(app);