mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
[tests] Split modules
This commit is contained in:
parent
5001341ea7
commit
a1b9296776
21
test/fixtures/module/modules/basic/index.js
vendored
21
test/fixtures/module/modules/basic/index.js
vendored
@ -1,20 +1,11 @@
|
|||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
module.exports = function basicModule (options) {
|
module.exports = function basicModule (options, resolve) {
|
||||||
return new Promise((resolve, reject) => {
|
// Add vendor
|
||||||
// Add simple vendor
|
this.addVendor('lodash')
|
||||||
this.addVendor('lodash')
|
|
||||||
|
|
||||||
// Add a plugin
|
// Add a plugin
|
||||||
this.addPlugin(path.resolve(__dirname, 'reverse.js'))
|
this.addPlugin(path.resolve(__dirname, 'reverse.js'))
|
||||||
|
|
||||||
// Add simple api endpoint
|
resolve()
|
||||||
this.addServerMiddleware({
|
|
||||||
path: '/api',
|
|
||||||
handler (req, res, next) {
|
|
||||||
res.end('It works!')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
12
test/fixtures/module/modules/middleware/index.js
vendored
Executable file
12
test/fixtures/module/modules/middleware/index.js
vendored
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
module.exports = function middlewareModule (options) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// Add /api endpoint
|
||||||
|
this.addServerMiddleware({
|
||||||
|
path: '/api',
|
||||||
|
handler (req, res, next) {
|
||||||
|
res.end('It works!')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
3
test/fixtures/module/nuxt.config.js
vendored
3
test/fixtures/module/nuxt.config.js
vendored
@ -1,5 +1,6 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
modules: [
|
modules: [
|
||||||
'~modules/basic'
|
'~modules/basic',
|
||||||
|
'~modules/middleware'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user