https://www.npmjs.com/package/serverless-http
serverless-http
Use existing web application frameworks in serverless environments. Latest version: 3.2.0, last published: 2 years ago. Start using serverless-http in your project by running `npm i serverless-http`. There are 247 other projects in the npm registry using s
www.npmjs.com
express만 사용하게되면 서버를 띄워야 코드를 실행시킬수 있는데
serverless-http 모듈이 추가되면 express를 서버리스로 실행시킬수 있게된다.
설치 명령어
npm install serverless-http
const serverless = require('serverless-http');
const express = require('express')
var cors = require('cors')
const app = express()
//POST 요청 받을 수 있게 만듬
app.use(express.json()) // for parsing
app.use(express.urlencoded({ extended: true }))
//POST API부분
module.exports.handler = serverless(app);
//원래 express 실행코드
//app.listen(3000)
'Back End > Node js' 카테고리의 다른 글
Node cors 기초 (0) | 2024.12.29 |
---|---|
node js 기본문법 (0) | 2024.12.29 |
npm 모듈다운 명령어 (0) | 2024.12.29 |