forked from opennextjs/opennextjs-netlify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
19 lines (15 loc) · 738 Bytes
/
setup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const { logTitle, logItem } = require('../../helpers/logger')
const setupNetlifyFunctionForPage = require('../../helpers/setupNetlifyFunctionForPage')
const asyncForEach = require('../../helpers/asyncForEach')
const getPages = require('./pages')
// Create a Netlify Function for every API endpoint
const setup = async ({ functionsPath, publishPath }) => {
logTitle('💫 Setting up API endpoints as Netlify Functions in', functionsPath)
const pages = await getPages({ publishPath })
// Create Netlify Function for every page
await asyncForEach(pages, async ({ filePath }) => {
logItem(filePath)
await setupNetlifyFunctionForPage({ filePath, functionsPath, isApiPage: true, publishPath })
})
}
module.exports = setup