This repository was archived by the owner on Feb 2, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +17
-104
lines changed Expand file tree Collapse file tree 4 files changed +17
-104
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import { resolve , join } from 'path'
2
2
3
+ import express from 'express'
4
+
3
5
import pkg from '../package.json'
4
6
5
7
import createRouter from './content/api'
@@ -49,6 +51,7 @@ export default function ContentModule (moduleOpts) {
49
51
componentsDir : '/components' ,
50
52
buildDir : `/content` ,
51
53
isStatic : userOptions . isStatic || process . env . STATIC || false ,
54
+ port : process . env . PORT || process . env . npm_package_config_nuxt_port || 3000 ,
52
55
53
56
content : contentOptions ( userOptions . content , {
54
57
page : null ,
@@ -98,10 +101,23 @@ export default function ContentModule (moduleOpts) {
98
101
} )
99
102
100
103
// 2. Add content API
104
+ const router = createRouter ( options )
101
105
106
+ // Add API when running `nuxt` & `nuxt build` (development and production)
102
107
this . addServerMiddleware ( {
103
108
path : api . serverPrefix ,
104
- handler : createRouter ( options )
109
+ handler : router
110
+ } )
111
+
112
+ // Add API when running `nuxt generate`
113
+ this . nuxt . plugin ( 'generator' , generator => {
114
+ const app = express ( )
115
+ app . use ( api . serverPrefix , router )
116
+ const server = app . listen ( options . port )
117
+
118
+ generator . plugin ( 'generated' , ( ) => {
119
+ server . close ( )
120
+ } )
105
121
} )
106
122
107
123
// 3. Add request helpers
Original file line number Diff line number Diff line change 22
22
" Static"
23
23
],
24
24
"license" : " MIT " ,
25
- "bin" : {
26
- "nuxtent" : " bin/nuxtent"
27
- },
28
25
"scripts" : {
29
26
"#<git hooks>" : " handled by husky" ,
30
27
"precommit" : " lint-staged" ,
You can’t perform that action at this time.
0 commit comments