2017-11-23 13:05:51 +00:00
|
|
|
/**
|
|
|
|
* server.js
|
|
|
|
*
|
|
|
|
* You can use the default server.js by simply running `next`,
|
|
|
|
* but a custom one is required to do paramaterized urls like
|
|
|
|
* blog/:slug.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* BENEVOLENT WEB LLC BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const {createServer} = require('http')
|
|
|
|
const next = require('next')
|
|
|
|
|
|
|
|
const port = parseInt(process.env.PORT, 10) || 3000
|
|
|
|
const dev = process.env.NODE_ENV !== 'production'
|
|
|
|
const app = next({dev})
|
2017-12-27 18:57:57 +00:00
|
|
|
const routes = require('./routes')
|
2017-11-23 13:05:51 +00:00
|
|
|
|
|
|
|
const handler = routes.getRequestHandler(app)
|
|
|
|
app.prepare().then(() => {
|
|
|
|
createServer(handler)
|
|
|
|
.listen(port, (err) => {
|
|
|
|
if (err) throw err
|
|
|
|
console.log(`> Ready on http://localhost:${port}`)
|
|
|
|
})
|
|
|
|
})
|