2018-02-24 23:17:04 +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.
|
|
|
|
*/
|
|
|
|
|
2018-12-17 16:34:32 +00:00
|
|
|
const { createServer } = require('http')
|
2018-02-24 23:17:04 +00:00
|
|
|
const next = require('next')
|
|
|
|
|
|
|
|
const port = parseInt(process.env.PORT, 10) || 3000
|
|
|
|
const dev = process.env.NODE_ENV !== 'production'
|
2018-12-17 16:34:32 +00:00
|
|
|
const app = next({ dev })
|
2018-02-24 23:17:04 +00:00
|
|
|
const routes = require('./routes')
|
|
|
|
|
|
|
|
const handler = routes.getRequestHandler(app)
|
|
|
|
app.prepare().then(() => {
|
2018-12-17 16:34:32 +00:00
|
|
|
createServer(handler).listen(port, err => {
|
|
|
|
if (err) throw err
|
|
|
|
console.log(`> Ready on http://localhost:${port}`)
|
|
|
|
})
|
2018-02-24 23:17:04 +00:00
|
|
|
})
|