Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
chore(package): remove nuxtent binary
Browse files Browse the repository at this point in the history
BREAKING CHANGE: replace `nuxtent generate` by `nuxt generate` in your project's package.json scripts
  • Loading branch information
medfreeman committed Sep 25, 2017
1 parent 79edcc7 commit 845aa8d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 104 deletions.
26 changes: 0 additions & 26 deletions bin/nuxtent

This file was deleted.

74 changes: 0 additions & 74 deletions bin/nuxtent-generate

This file was deleted.

18 changes: 17 additions & 1 deletion lib/module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { resolve, join } from 'path'

import express from 'express'

import pkg from '../package.json'

import createRouter from './content/api'
Expand Down Expand Up @@ -49,6 +51,7 @@ export default function ContentModule (moduleOpts) {
componentsDir: '/components',
buildDir: `/content`,
isStatic: userOptions.isStatic || process.env.STATIC || false,
port: process.env.PORT || process.env.npm_package_config_nuxt_port || 3000,

content: contentOptions(userOptions.content, {
page: null,
Expand Down Expand Up @@ -98,10 +101,23 @@ export default function ContentModule (moduleOpts) {
})

// 2. Add content API
const router = createRouter(options)

// Add API when running `nuxt` & `nuxt build` (development and production)
this.addServerMiddleware({
path: api.serverPrefix,
handler: createRouter(options)
handler: router
})

// Add API when running `nuxt generate`
this.nuxt.plugin('generator', generator => {
const app = express()
app.use(api.serverPrefix, router)
const server = app.listen(options.port)

generator.plugin('generated', () => {
server.close()
})
})

// 3. Add request helpers
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
"Static"
],
"license": "MIT ",
"bin": {
"nuxtent": "bin/nuxtent"
},
"scripts": {
"#<git hooks>": "handled by husky",
"precommit": "lint-staged",
Expand Down

0 comments on commit 845aa8d

Please sign in to comment.