mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Upgrade standard.js (#4064)
* Upgrade standard.js # Conflicts: # yarn.lock * Upgrade babel-eslint
This commit is contained in:
parent
603b90ce02
commit
ebf0c47c25
|
@ -43,7 +43,7 @@ if (!existsSync(join(dir, 'pages'))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
build(dir)
|
build(dir)
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
40
bin/next-dev
40
bin/next-dev
|
@ -54,23 +54,23 @@ if (!existsSync(join(dir, 'pages'))) {
|
||||||
|
|
||||||
const srv = new Server({ dir, dev: true })
|
const srv = new Server({ dir, dev: true })
|
||||||
srv.start(argv.port, argv.hostname)
|
srv.start(argv.port, argv.hostname)
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
if (!process.env.NOW) {
|
if (!process.env.NOW) {
|
||||||
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
if (err.code === 'EADDRINUSE') {
|
if (err.code === 'EADDRINUSE') {
|
||||||
let errorMessage = `Port ${argv.port} is already in use.`
|
let errorMessage = `Port ${argv.port} is already in use.`
|
||||||
const pkgAppPath = require('find-up').sync('package.json', {
|
const pkgAppPath = require('find-up').sync('package.json', {
|
||||||
cwd: dir
|
cwd: dir
|
||||||
})
|
})
|
||||||
const appPackage = JSON.parse(readFileSync(pkgAppPath, 'utf8'))
|
const appPackage = JSON.parse(readFileSync(pkgAppPath, 'utf8'))
|
||||||
const nextScript = Object.entries(appPackage.scripts).find(scriptLine => scriptLine[1] === 'next')
|
const nextScript = Object.entries(appPackage.scripts).find(scriptLine => scriptLine[1] === 'next')
|
||||||
if (nextScript) errorMessage += `\nUse \`npm run ${nextScript[0]} -- -p <some other port>\`.`
|
if (nextScript) errorMessage += `\nUse \`npm run ${nextScript[0]} -- -p <some other port>\`.`
|
||||||
console.error(errorMessage)
|
console.error(errorMessage)
|
||||||
} else {
|
} else {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
process.nextTick(() => process.exit(1))
|
process.nextTick(() => process.exit(1))
|
||||||
})
|
})
|
||||||
|
|
|
@ -46,12 +46,12 @@ const dir = resolve(argv._[0] || '.')
|
||||||
|
|
||||||
const srv = new Server({ dir })
|
const srv = new Server({ dir })
|
||||||
srv.start(argv.port, argv.hostname)
|
srv.start(argv.port, argv.hostname)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (!process.env.NOW) {
|
if (!process.env.NOW) {
|
||||||
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
console.log(`> Ready on http://${argv.hostname ? argv.hostname : 'localhost'}:${argv.port}`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,14 +8,14 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
|
res.setHeader('Content-Type', 'text/html; charset=iso-8859-2')
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ exports['default'] = {
|
||||||
// Logging levels of task workers
|
// Logging levels of task workers
|
||||||
workerLogging: {
|
workerLogging: {
|
||||||
failure: 'error', // task failure
|
failure: 'error', // task failure
|
||||||
success: 'info', // task success
|
success: 'info', // task success
|
||||||
start: 'info',
|
start: 'info',
|
||||||
end: 'info',
|
end: 'info',
|
||||||
cleaning_worker: 'info',
|
cleaning_worker: 'info',
|
||||||
|
|
|
@ -7,27 +7,27 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.get('/a', (req, res) => {
|
server.get('/a', (req, res) => {
|
||||||
return app.render(req, res, '/b', req.query)
|
return app.render(req, res, '/b', req.query)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('/b', (req, res) => {
|
server.get('/b', (req, res) => {
|
||||||
return app.render(req, res, '/a', req.query)
|
return app.render(req, res, '/a', req.query)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('/posts/:id', (req, res) => {
|
server.get('/posts/:id', (req, res) => {
|
||||||
return app.render(req, res, '/posts', { id: req.params.id })
|
return app.render(req, res, '/posts', { id: req.params.id })
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('*', (req, res) => {
|
server.get('*', (req, res) => {
|
||||||
return handle(req, res)
|
return handle(req, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.listen(port, (err) => {
|
server.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -7,23 +7,23 @@ const app = Next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = fastify()
|
const server = fastify()
|
||||||
|
|
||||||
server.get('/a', (req, res) => {
|
server.get('/a', (req, res) => {
|
||||||
return app.render(req.req, res.res, '/a', req.query)
|
return app.render(req.req, res.res, '/a', req.query)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('/b', (req, res) => {
|
server.get('/b', (req, res) => {
|
||||||
return app.render(req.req, res.res, '/b', req.query)
|
return app.render(req.req, res.res, '/b', req.query)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('/*', (req, res) => {
|
server.get('/*', (req, res) => {
|
||||||
return handle(req.req, res.res)
|
return handle(req.req, res.res)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.listen(port, (err) => {
|
server.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -10,37 +10,37 @@ const server = new Hapi.Server({
|
||||||
})
|
})
|
||||||
|
|
||||||
app
|
app
|
||||||
.prepare()
|
.prepare()
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
server.route({
|
server.route({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/a',
|
path: '/a',
|
||||||
handler: pathWrapper(app, '/a')
|
handler: pathWrapper(app, '/a')
|
||||||
})
|
})
|
||||||
|
|
||||||
server.route({
|
server.route({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/b',
|
path: '/b',
|
||||||
handler: pathWrapper(app, '/b')
|
handler: pathWrapper(app, '/b')
|
||||||
})
|
})
|
||||||
|
|
||||||
server.route({
|
server.route({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/_next/{p*}', /* next specific routes */
|
path: '/_next/{p*}', /* next specific routes */
|
||||||
handler: nextHandlerWrapper(app)
|
handler: nextHandlerWrapper(app)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.route({
|
server.route({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
path: '/{p*}', /* catch all route */
|
path: '/{p*}', /* catch all route */
|
||||||
handler: defaultHandlerWrapper(app)
|
handler: defaultHandlerWrapper(app)
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await server.start()
|
await server.start()
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('Error starting server')
|
console.log('Error starting server')
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,32 +8,32 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = new Koa()
|
const server = new Koa()
|
||||||
const router = new Router()
|
const router = new Router()
|
||||||
|
|
||||||
router.get('/a', async ctx => {
|
router.get('/a', async ctx => {
|
||||||
await app.render(ctx.req, ctx.res, '/b', ctx.query)
|
await app.render(ctx.req, ctx.res, '/b', ctx.query)
|
||||||
ctx.respond = false
|
ctx.respond = false
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('/b', async ctx => {
|
router.get('/b', async ctx => {
|
||||||
await app.render(ctx.req, ctx.res, '/a', ctx.query)
|
await app.render(ctx.req, ctx.res, '/a', ctx.query)
|
||||||
ctx.respond = false
|
ctx.respond = false
|
||||||
})
|
})
|
||||||
|
|
||||||
router.get('*', async ctx => {
|
router.get('*', async ctx => {
|
||||||
await handle(ctx.req, ctx.res)
|
await handle(ctx.req, ctx.res)
|
||||||
ctx.respond = false
|
ctx.respond = false
|
||||||
})
|
})
|
||||||
|
|
||||||
server.use(async (ctx, next) => {
|
server.use(async (ctx, next) => {
|
||||||
ctx.res.statusCode = 200
|
ctx.res.statusCode = 200
|
||||||
await next()
|
await next()
|
||||||
})
|
})
|
||||||
|
|
||||||
server.use(router.routes())
|
server.use(router.routes())
|
||||||
server.listen(port, () => {
|
server.listen(port, () => {
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -8,21 +8,21 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const { pathname, query } = parsedUrl
|
const { pathname, query } = parsedUrl
|
||||||
|
|
||||||
if (pathname === '/a') {
|
if (pathname === '/a') {
|
||||||
app.render(req, res, '/b', query)
|
app.render(req, res, '/b', query)
|
||||||
} else if (pathname === '/b') {
|
} else if (pathname === '/b') {
|
||||||
app.render(req, res, '/a', query)
|
app.render(req, res, '/a', query)
|
||||||
} else {
|
} else {
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -8,21 +8,21 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const { pathname, query } = parsedUrl
|
const { pathname, query } = parsedUrl
|
||||||
|
|
||||||
if (pathname === '/a') {
|
if (pathname === '/a') {
|
||||||
app.render(req, res, '/b', query)
|
app.render(req, res, '/b', query)
|
||||||
} else if (pathname === '/b') {
|
} else if (pathname === '/b') {
|
||||||
app.render(req, res, '/a', query)
|
app.render(req, res, '/a', query)
|
||||||
} else {
|
} else {
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -6,23 +6,23 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.get('/', (req, res) => {
|
server.get('/', (req, res) => {
|
||||||
return handle(req, res)
|
return handle(req, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('*', (req, res) => {
|
server.get('*', (req, res) => {
|
||||||
return handle(req, res)
|
return handle(req, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.listen(3000, (err) => {
|
server.listen(3000, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log('> Ready on http://localhost:3000')
|
console.log('> Ready on http://localhost:3000')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch((ex) => {
|
||||||
|
console.error(ex.stack)
|
||||||
|
process.exit(1)
|
||||||
})
|
})
|
||||||
})
|
|
||||||
.catch((ex) => {
|
|
||||||
console.error(ex.stack)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
|
|
|
@ -11,21 +11,21 @@ const route = pathMatch()
|
||||||
const match = route('/blog/:id')
|
const match = route('/blog/:id')
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const { pathname, query } = parse(req.url, true)
|
const { pathname, query } = parse(req.url, true)
|
||||||
const params = match(pathname)
|
const params = match(pathname)
|
||||||
if (params === false) {
|
if (params === false) {
|
||||||
handle(req, res)
|
handle(req, res)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// assigning `query` into the params means that we still
|
// assigning `query` into the params means that we still
|
||||||
// get the query string passed to our application
|
// get the query string passed to our application
|
||||||
// i.e. /blog/foo?show-comments=true
|
// i.e. /blog/foo?show-comments=true
|
||||||
app.render(req, res, '/blog', Object.assign(params, query))
|
app.render(req, res, '/blog', Object.assign(params, query))
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -9,23 +9,23 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const rootStaticFiles = [
|
const rootStaticFiles = [
|
||||||
'/robots.txt',
|
'/robots.txt',
|
||||||
'/sitemap.xml',
|
'/sitemap.xml',
|
||||||
'/favicon.ico'
|
'/favicon.ico'
|
||||||
]
|
]
|
||||||
if (rootStaticFiles.indexOf(parsedUrl.pathname) > -1) {
|
if (rootStaticFiles.indexOf(parsedUrl.pathname) > -1) {
|
||||||
const path = join(__dirname, 'static', parsedUrl.pathname)
|
const path = join(__dirname, 'static', parsedUrl.pathname)
|
||||||
app.serveStatic(req, res, path)
|
app.serveStatic(req, res, path)
|
||||||
} else {
|
} else {
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -14,28 +14,28 @@ const ssrCache = new LRUCache({
|
||||||
})
|
})
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
// Use the `renderAndCache` utility defined below to serve pages
|
// Use the `renderAndCache` utility defined below to serve pages
|
||||||
server.get('/', (req, res) => {
|
server.get('/', (req, res) => {
|
||||||
renderAndCache(req, res, '/')
|
renderAndCache(req, res, '/')
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('/blog/:id', (req, res) => {
|
server.get('/blog/:id', (req, res) => {
|
||||||
const queryParams = { id: req.params.id }
|
const queryParams = { id: req.params.id }
|
||||||
renderAndCache(req, res, '/blog', queryParams)
|
renderAndCache(req, res, '/blog', queryParams)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('*', (req, res) => {
|
server.get('*', (req, res) => {
|
||||||
return handle(req, res)
|
return handle(req, res)
|
||||||
})
|
})
|
||||||
|
|
||||||
server.listen(port, (err) => {
|
server.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NB: make sure to modify this to take into account anything that should trigger
|
* NB: make sure to modify this to take into account anything that should trigger
|
||||||
|
|
|
@ -18,13 +18,13 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -17,13 +17,13 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -11,13 +11,13 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable */
|
||||||
const withCss = require('@zeit/next-css')
|
const withCss = require('@zeit/next-css')
|
||||||
|
|
||||||
// fix: prevents error when .css files are required by node
|
// fix: prevents error when .css files are required by node
|
||||||
|
|
|
@ -10,24 +10,24 @@ export default connect({
|
||||||
mounted: signal`clock.mounted`,
|
mounted: signal`clock.mounted`,
|
||||||
unMounted: signal`clock.unMounted`
|
unMounted: signal`clock.unMounted`
|
||||||
},
|
},
|
||||||
class Page extends React.Component {
|
class Page extends React.Component {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
this.props.mounted()
|
this.props.mounted()
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount () {
|
|
||||||
this.props.unMounted()
|
|
||||||
}
|
|
||||||
render () {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1>{this.props.title}</h1>
|
|
||||||
<Clock lastUpdate={this.props.lastUpdate} light={this.props.light} />
|
|
||||||
<nav>
|
|
||||||
<Link href={this.props.linkTo}><a>Navigate</a></Link>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount () {
|
||||||
|
this.props.unMounted()
|
||||||
|
}
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<h1>{this.props.title}</h1>
|
||||||
|
<Clock lastUpdate={this.props.lastUpdate} light={this.props.light} />
|
||||||
|
<nav>
|
||||||
|
<Link href={this.props.linkTo}><a>Navigate</a></Link>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {
|
||||||
RichUtils,
|
RichUtils,
|
||||||
convertToRaw,
|
convertToRaw,
|
||||||
convertFromRaw
|
convertFromRaw
|
||||||
} from 'draft-js'
|
} from 'draft-js'
|
||||||
|
|
||||||
export default class App extends React.Component {
|
export default class App extends React.Component {
|
||||||
constructor (props) {
|
constructor (props) {
|
||||||
|
@ -62,7 +62,7 @@ export default class App extends React.Component {
|
||||||
setSelectionXY = () => {
|
setSelectionXY = () => {
|
||||||
var r = window.getSelection().getRangeAt(0).getBoundingClientRect()
|
var r = window.getSelection().getRangeAt(0).getBoundingClientRect()
|
||||||
var relative = document.body.parentNode.getBoundingClientRect()
|
var relative = document.body.parentNode.getBoundingClientRect()
|
||||||
// 2-a Set the selection coordinates in the state
|
// 2-a Set the selection coordinates in the state
|
||||||
this.setState({
|
this.setState({
|
||||||
selectionCoordinates: r,
|
selectionCoordinates: r,
|
||||||
windowWidth: relative.width,
|
windowWidth: relative.width,
|
||||||
|
@ -176,7 +176,7 @@ export default class App extends React.Component {
|
||||||
this.elemHeight = elem ? elem.clientHeight : 0
|
this.elemHeight = elem ? elem.clientHeight : 0
|
||||||
}}
|
}}
|
||||||
style={toolbarStyle}
|
style={toolbarStyle}
|
||||||
>
|
>
|
||||||
<ToolBar
|
<ToolBar
|
||||||
editorState={editorState}
|
editorState={editorState}
|
||||||
onToggle={this.toggleToolbar}
|
onToggle={this.toggleToolbar}
|
||||||
|
@ -261,8 +261,8 @@ const ToolBar = (props) => {
|
||||||
label={toolbarItem.label}
|
label={toolbarItem.label}
|
||||||
onToggle={props.onToggle}
|
onToggle={props.onToggle}
|
||||||
style={toolbarItem.style}
|
style={toolbarItem.style}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// TODO firebase client config
|
// TODO firebase client config
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// TODO firebase server config
|
// TODO firebase server config
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,8 +90,8 @@ export default class Index extends Component {
|
||||||
return <div>
|
return <div>
|
||||||
{
|
{
|
||||||
user
|
user
|
||||||
? <button onClick={this.handleLogout}>Logout</button>
|
? <button onClick={this.handleLogout}>Logout</button>
|
||||||
: <button onClick={this.handleLogin}>Login</button>
|
: <button onClick={this.handleLogin}>Login</button>
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
user &&
|
user &&
|
||||||
|
|
|
@ -16,49 +16,49 @@ const firebase = admin.initializeApp({
|
||||||
}, 'server')
|
}, 'server')
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
server.use(bodyParser.json())
|
server.use(bodyParser.json())
|
||||||
server.use(session({
|
server.use(session({
|
||||||
secret: 'geheimnis',
|
secret: 'geheimnis',
|
||||||
saveUninitialized: true,
|
saveUninitialized: true,
|
||||||
store: new FileStore({path: '/tmp/sessions', secret: 'geheimnis'}),
|
store: new FileStore({path: '/tmp/sessions', secret: 'geheimnis'}),
|
||||||
resave: false,
|
resave: false,
|
||||||
rolling: true,
|
rolling: true,
|
||||||
httpOnly: true,
|
httpOnly: true,
|
||||||
cookie: { maxAge: 604800000 } // week
|
cookie: { maxAge: 604800000 } // week
|
||||||
}))
|
}))
|
||||||
|
|
||||||
server.use((req, res, next) => {
|
server.use((req, res, next) => {
|
||||||
req.firebaseServer = firebase
|
req.firebaseServer = firebase
|
||||||
next()
|
next()
|
||||||
|
})
|
||||||
|
|
||||||
|
server.post('/api/login', (req, res) => {
|
||||||
|
if (!req.body) return res.sendStatus(400)
|
||||||
|
|
||||||
|
const token = req.body.token
|
||||||
|
firebase.auth().verifyIdToken(token)
|
||||||
|
.then((decodedToken) => {
|
||||||
|
req.session.decodedToken = decodedToken
|
||||||
|
return decodedToken
|
||||||
|
})
|
||||||
|
.then((decodedToken) => res.json({ status: true, decodedToken }))
|
||||||
|
.catch((error) => res.json({ error }))
|
||||||
|
})
|
||||||
|
|
||||||
|
server.post('/api/logout', (req, res) => {
|
||||||
|
req.session.decodedToken = null
|
||||||
|
res.json({ status: true })
|
||||||
|
})
|
||||||
|
|
||||||
|
server.get('*', (req, res) => {
|
||||||
|
return handle(req, res)
|
||||||
|
})
|
||||||
|
|
||||||
|
server.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
server.post('/api/login', (req, res) => {
|
|
||||||
if (!req.body) return res.sendStatus(400)
|
|
||||||
|
|
||||||
const token = req.body.token
|
|
||||||
firebase.auth().verifyIdToken(token)
|
|
||||||
.then((decodedToken) => {
|
|
||||||
req.session.decodedToken = decodedToken
|
|
||||||
return decodedToken
|
|
||||||
})
|
|
||||||
.then((decodedToken) => res.json({ status: true, decodedToken }))
|
|
||||||
.catch((error) => res.json({ error }))
|
|
||||||
})
|
|
||||||
|
|
||||||
server.post('/api/logout', (req, res) => {
|
|
||||||
req.session.decodedToken = null
|
|
||||||
res.json({ status: true })
|
|
||||||
})
|
|
||||||
|
|
||||||
server.get('*', (req, res) => {
|
|
||||||
return handle(req, res)
|
|
||||||
})
|
|
||||||
|
|
||||||
server.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -11,12 +11,12 @@ module.exports = {
|
||||||
name: 'dist/[path][name].[ext]'
|
name: 'dist/[path][name].[ext]'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
use: ['babel-loader', 'raw-loader', 'postcss-loader']
|
use: ['babel-loader', 'raw-loader', 'postcss-loader']
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
{
|
{
|
||||||
test: /\.s(a|c)ss$/,
|
test: /\.s(a|c)ss$/,
|
||||||
use: ['babel-loader', 'raw-loader', 'postcss-loader',
|
use: ['babel-loader', 'raw-loader', 'postcss-loader',
|
||||||
|
|
|
@ -8,10 +8,10 @@ const app = next({ dev })
|
||||||
const handler = routes.getRequestHandler(app)
|
const handler = routes.getRequestHandler(app)
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer(handler)
|
createServer(handler)
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ const app = next({ dev })
|
||||||
const handler = routes.getRequestHandler(app)
|
const handler = routes.getRequestHandler(app)
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer(handler)
|
createServer(handler)
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => handle(req, res, parse(req.url, true).pathname))
|
createServer((req, res) => handle(req, res, parse(req.url, true).pathname))
|
||||||
.listen(port, (err) => {
|
.listen(port, (err) => {
|
||||||
if (err) throw err
|
if (err) throw err
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
/* eslint no-extend-native: 0 */
|
/* eslint no-extend-native: 0 */
|
||||||
|
|
||||||
// Add your polyfills
|
|
||||||
// This files runs at the very beginning (even before React and Next.js core)
|
|
||||||
|
|
||||||
console.log('Load your polyfills')
|
|
||||||
|
|
||||||
// core-js comes with Next.js. So, you can import it like below
|
// core-js comes with Next.js. So, you can import it like below
|
||||||
import includes from 'core-js/library/fn/string/virtual/includes'
|
import includes from 'core-js/library/fn/string/virtual/includes'
|
||||||
import repeat from 'core-js/library/fn/string/virtual/repeat'
|
import repeat from 'core-js/library/fn/string/virtual/repeat'
|
||||||
|
|
||||||
|
// Add your polyfills
|
||||||
|
// This files runs at the very beginning (even before React and Next.js core)
|
||||||
|
console.log('Load your polyfills')
|
||||||
|
|
||||||
String.prototype.includes = includes
|
String.prototype.includes = includes
|
||||||
String.prototype.repeat = repeat
|
String.prototype.repeat = repeat
|
||||||
|
|
|
@ -8,13 +8,13 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
Router.forEachPattern((page, pattern, defaultParams) => server.get(pattern, (req, res) =>
|
Router.forEachPattern((page, pattern, defaultParams) => server.get(pattern, (req, res) =>
|
||||||
app.render(req, res, `/${page}`, Object.assign({}, defaultParams, req.query, req.params))
|
app.render(req, res, `/${page}`, Object.assign({}, defaultParams, req.query, req.params))
|
||||||
))
|
))
|
||||||
|
|
||||||
server.get('*', (req, res) => handle(req, res))
|
server.get('*', (req, res) => handle(req, res))
|
||||||
server.listen(port)
|
server.listen(port)
|
||||||
})
|
})
|
||||||
|
|
|
@ -22,8 +22,8 @@ export default class extends Document {
|
||||||
// should render on <head>
|
// should render on <head>
|
||||||
get helmetHeadComponents () {
|
get helmetHeadComponents () {
|
||||||
return Object.keys(this.props.helmet)
|
return Object.keys(this.props.helmet)
|
||||||
.filter(el => el !== 'htmlAttributes' && el !== 'bodyAttributes')
|
.filter(el => el !== 'htmlAttributes' && el !== 'bodyAttributes')
|
||||||
.map(el => this.props.helmet[el].toComponent())
|
.map(el => this.props.helmet[el].toComponent())
|
||||||
}
|
}
|
||||||
|
|
||||||
get helmetJsx () {
|
get helmetJsx () {
|
||||||
|
|
|
@ -39,5 +39,5 @@ export default connect(
|
||||||
character: state.character,
|
character: state.character,
|
||||||
error: state.error,
|
error: state.error,
|
||||||
isFetchedOnServer: state.isFetchedOnServer
|
isFetchedOnServer: state.isFetchedOnServer
|
||||||
}),
|
})
|
||||||
)(CharacterInfo)
|
)(CharacterInfo)
|
||||||
|
|
|
@ -46,5 +46,5 @@ export default withRedux(
|
||||||
{
|
{
|
||||||
startFetchingCharacters: actions.startFetchingCharacters,
|
startFetchingCharacters: actions.startFetchingCharacters,
|
||||||
stopFetchingCharacters: actions.stopFetchingCharacters
|
stopFetchingCharacters: actions.stopFetchingCharacters
|
||||||
},
|
}
|
||||||
)(Counter)
|
)(Counter)
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { rootEpic } from './epics'
|
||||||
|
|
||||||
export default function initStore (initialState) {
|
export default function initStore (initialState) {
|
||||||
const epicMiddleware = createEpicMiddleware(rootEpic)
|
const epicMiddleware = createEpicMiddleware(rootEpic)
|
||||||
const logger = createLogger({ collapsed: true }) // log every action to see what's happening behind the scenes.
|
const logger = createLogger({ collapsed: true }) // log every action to see what's happening behind the scenes.
|
||||||
const reduxMiddleware = applyMiddleware(thunkMiddleware, epicMiddleware, logger)
|
const reduxMiddleware = applyMiddleware(thunkMiddleware, epicMiddleware, logger)
|
||||||
|
|
||||||
return createStore(reducer, initialState, reduxMiddleware)
|
return createStore(reducer, initialState, reduxMiddleware)
|
||||||
|
|
|
@ -15,7 +15,7 @@ module.exports = {
|
||||||
query: { id: post.id }
|
query: { id: post.id }
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
{},
|
{}
|
||||||
)
|
)
|
||||||
|
|
||||||
// combine the map of post pages with the home
|
// combine the map of post pages with the home
|
||||||
|
|
|
@ -7,22 +7,22 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const server = express()
|
const server = express()
|
||||||
|
|
||||||
// custom route for posts
|
// custom route for posts
|
||||||
server.get('/post/:id', (req, res) => {
|
server.get('/post/:id', (req, res) => {
|
||||||
return app.render(req, res, '/post', {
|
return app.render(req, res, '/post', {
|
||||||
id: req.params.id
|
id: req.params.id
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
server.get('*', (req, res) => {
|
||||||
|
return handle(req, res)
|
||||||
|
})
|
||||||
|
|
||||||
|
server.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
server.get('*', (req, res) => {
|
|
||||||
return handle(req, res)
|
|
||||||
})
|
|
||||||
|
|
||||||
server.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -9,20 +9,20 @@ const app = next({ dev })
|
||||||
const handle = app.getRequestHandler()
|
const handle = app.getRequestHandler()
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const parsedUrl = parse(req.url, true)
|
const parsedUrl = parse(req.url, true)
|
||||||
const { pathname } = parsedUrl
|
const { pathname } = parsedUrl
|
||||||
|
|
||||||
if (pathname === '/service-worker.js') {
|
if (pathname === '/service-worker.js') {
|
||||||
const filePath = join(__dirname, '.next', pathname)
|
const filePath = join(__dirname, '.next', pathname)
|
||||||
app.serveStatic(req, res, filePath)
|
app.serveStatic(req, res, filePath)
|
||||||
} else {
|
} else {
|
||||||
handle(req, res, parsedUrl)
|
handle(req, res, parsedUrl)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -244,15 +244,15 @@ module.exports = {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
textSizes: {
|
textSizes: {
|
||||||
'xs': '.75rem', // 12px
|
'xs': '.75rem', // 12px
|
||||||
'sm': '.875rem', // 14px
|
'sm': '.875rem', // 14px
|
||||||
'base': '1rem', // 16px
|
'base': '1rem', // 16px
|
||||||
'lg': '1.125rem', // 18px
|
'lg': '1.125rem', // 18px
|
||||||
'xl': '1.25rem', // 20px
|
'xl': '1.25rem', // 20px
|
||||||
'2xl': '1.5rem', // 24px
|
'2xl': '1.5rem', // 24px
|
||||||
'3xl': '1.875rem', // 30px
|
'3xl': '1.875rem', // 30px
|
||||||
'4xl': '2.25rem', // 36px
|
'4xl': '2.25rem', // 36px
|
||||||
'5xl': '3rem' // 48px
|
'5xl': '3rem' // 48px
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -5,7 +5,7 @@ const {API_URL} = env
|
||||||
|
|
||||||
export default class extends React.Component {
|
export default class extends React.Component {
|
||||||
static async getInitialProps () {
|
static async getInitialProps () {
|
||||||
// fetch(`${API_URL}/some-path`)
|
// fetch(`${API_URL}/some-path`)
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,19 +11,19 @@ const route = pathMatch()
|
||||||
const match = route('/about/:name')
|
const match = route('/about/:name')
|
||||||
|
|
||||||
app.prepare()
|
app.prepare()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
createServer((req, res) => {
|
createServer((req, res) => {
|
||||||
const { pathname } = parse(req.url)
|
const { pathname } = parse(req.url)
|
||||||
const params = match(pathname)
|
const params = match(pathname)
|
||||||
if (params === false) {
|
if (params === false) {
|
||||||
handle(req, res)
|
handle(req, res)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app.render(req, res, '/about', params)
|
app.render(req, res, '/about', params)
|
||||||
|
})
|
||||||
|
.listen(port, (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
console.log(`> Ready on http://localhost:${port}`)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.listen(port, (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
console.log(`> Ready on http://localhost:${port}`)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ export default class EventEmitter {
|
||||||
|
|
||||||
emit (event, ...data) {
|
emit (event, ...data) {
|
||||||
if (!this.listeners[event]) return
|
if (!this.listeners[event]) return
|
||||||
this.listeners[event].forEach(cb => cb(...data))
|
this.listeners[event].forEach(cb => cb(...data)) // eslint-disable-line standard/no-callback-literal
|
||||||
}
|
}
|
||||||
|
|
||||||
off (event, cb) {
|
off (event, cb) {
|
||||||
|
|
|
@ -10,8 +10,8 @@ export default ({ error, error: { name, message, module } }) => (
|
||||||
{module ? <h1 style={styles.heading}>Error in {module.rawRequest}</h1> : null}
|
{module ? <h1 style={styles.heading}>Error in {module.rawRequest}</h1> : null}
|
||||||
{
|
{
|
||||||
name === 'ModuleBuildError'
|
name === 'ModuleBuildError'
|
||||||
? <pre style={styles.stack} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} />
|
? <pre style={styles.stack} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} />
|
||||||
: <StackTrace error={error} />
|
: <StackTrace error={error} />
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|
36
lib/head.js
36
lib/head.js
|
@ -18,24 +18,24 @@ export function defaultHead () {
|
||||||
|
|
||||||
function reduceComponents (components) {
|
function reduceComponents (components) {
|
||||||
return components
|
return components
|
||||||
.map((c) => c.props.children)
|
.map((c) => c.props.children)
|
||||||
.map((children) => React.Children.toArray(children))
|
.map((children) => React.Children.toArray(children))
|
||||||
.reduce((a, b) => a.concat(b), [])
|
.reduce((a, b) => a.concat(b), [])
|
||||||
.reduce((a, b) => {
|
.reduce((a, b) => {
|
||||||
if (React.Fragment && b.type === React.Fragment) {
|
if (React.Fragment && b.type === React.Fragment) {
|
||||||
return a.concat(React.Children.toArray(b.props.children))
|
return a.concat(React.Children.toArray(b.props.children))
|
||||||
}
|
}
|
||||||
return a.concat(b)
|
return a.concat(b)
|
||||||
}, [])
|
}, [])
|
||||||
.reverse()
|
.reverse()
|
||||||
.concat(...defaultHead())
|
.concat(...defaultHead())
|
||||||
.filter((c) => !!c)
|
.filter((c) => !!c)
|
||||||
.filter(unique())
|
.filter(unique())
|
||||||
.reverse()
|
.reverse()
|
||||||
.map((c) => {
|
.map((c) => {
|
||||||
const className = (c.props && c.props.className ? c.props.className + ' ' : '') + 'next-head'
|
const className = (c.props && c.props.className ? c.props.className + ' ' : '') + 'next-head'
|
||||||
return React.cloneElement(c, { className })
|
return React.cloneElement(c, { className })
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapOnServer (head) {
|
function mapOnServer (head) {
|
||||||
|
|
|
@ -355,7 +355,7 @@ export default class Router {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchRoute (route) {
|
async fetchRoute (route) {
|
||||||
return await this.pageLoader.loadPage(route)
|
return this.pageLoader.loadPage(route)
|
||||||
}
|
}
|
||||||
|
|
||||||
abortComponentLoad (as) {
|
abortComponentLoad (as) {
|
||||||
|
|
|
@ -113,7 +113,7 @@
|
||||||
"@taskr/esnext": "1.1.0",
|
"@taskr/esnext": "1.1.0",
|
||||||
"@taskr/watch": "1.1.0",
|
"@taskr/watch": "1.1.0",
|
||||||
"@zeit/next-css": "0.0.7",
|
"@zeit/next-css": "0.0.7",
|
||||||
"babel-eslint": "8.0.1",
|
"babel-eslint": "8.2.2",
|
||||||
"babel-jest": "21.2.0",
|
"babel-jest": "21.2.0",
|
||||||
"babel-plugin-istanbul": "4.1.5",
|
"babel-plugin-istanbul": "4.1.5",
|
||||||
"babel-plugin-transform-remove-strict-mode": "0.0.2",
|
"babel-plugin-transform-remove-strict-mode": "0.0.2",
|
||||||
|
@ -139,7 +139,7 @@
|
||||||
"react": "16.2.0",
|
"react": "16.2.0",
|
||||||
"react-dom": "16.2.0",
|
"react-dom": "16.2.0",
|
||||||
"rimraf": "2.6.2",
|
"rimraf": "2.6.2",
|
||||||
"standard": "9.0.2",
|
"standard": "11.0.1",
|
||||||
"taskr": "1.1.0",
|
"taskr": "1.1.0",
|
||||||
"wd": "1.4.1"
|
"wd": "1.4.1"
|
||||||
},
|
},
|
||||||
|
|
|
@ -34,7 +34,7 @@ function getRoute (loaderContext) {
|
||||||
const pagesDir = resolve(loaderContext.options.context, 'pages')
|
const pagesDir = resolve(loaderContext.options.context, 'pages')
|
||||||
const { resourcePath } = loaderContext
|
const { resourcePath } = loaderContext
|
||||||
const dir = [pagesDir, nextPagesDir]
|
const dir = [pagesDir, nextPagesDir]
|
||||||
.find((d) => resourcePath.indexOf(d) === 0)
|
.find((d) => resourcePath.indexOf(d) === 0)
|
||||||
const path = relative(dir, resourcePath)
|
const path = relative(dir, resourcePath)
|
||||||
return '/' + path.replace(/((^|\/)index)?\.js$/, '')
|
return '/' + path.replace(/((^|\/)index)?\.js$/, '')
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,12 @@ class PageChunkTemplatePlugin {
|
||||||
|
|
||||||
let routeName = MATCH_ROUTE_NAME.exec(chunk.name)[1]
|
let routeName = MATCH_ROUTE_NAME.exec(chunk.name)[1]
|
||||||
|
|
||||||
// We need to convert \ into / when we are in windows
|
// We need to convert \ into / when we are in windows
|
||||||
// to get the proper route name
|
// to get the proper route name
|
||||||
// Here we need to do windows check because it's possible
|
// Here we need to do windows check because it's possible
|
||||||
// to have "\" in the filename in unix.
|
// to have "\" in the filename in unix.
|
||||||
// Anyway if someone did that, he'll be having issues here.
|
// Anyway if someone did that, he'll be having issues here.
|
||||||
// But that's something we cannot avoid.
|
// But that's something we cannot avoid.
|
||||||
if (/^win/.test(process.platform)) {
|
if (/^win/.test(process.platform)) {
|
||||||
routeName = routeName.replace(/\\/g, '/')
|
routeName = routeName.replace(/\\/g, '/')
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ export default class UnlinkFilePlugin {
|
||||||
apply (compiler) {
|
apply (compiler) {
|
||||||
compiler.plugin('after-emit', (compilation, callback) => {
|
compiler.plugin('after-emit', (compilation, callback) => {
|
||||||
const removed = Object.keys(this.prevAssets)
|
const removed = Object.keys(this.prevAssets)
|
||||||
.filter((a) => IS_BUNDLED_PAGE.test(a) && !compilation.assets[a])
|
.filter((a) => IS_BUNDLED_PAGE.test(a) && !compilation.assets[a])
|
||||||
|
|
||||||
this.prevAssets = compilation.assets
|
this.prevAssets = compilation.assets
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ export default class UnlinkFilePlugin {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.then(() => callback(), callback)
|
.then(() => callback(), callback)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,11 +149,11 @@ export default class HotReloader {
|
||||||
)
|
)
|
||||||
|
|
||||||
const failedChunkNames = new Set(compilation.errors
|
const failedChunkNames = new Set(compilation.errors
|
||||||
.map((e) => e.module.reasons)
|
.map((e) => e.module.reasons)
|
||||||
.reduce((a, b) => a.concat(b), [])
|
.reduce((a, b) => a.concat(b), [])
|
||||||
.map((r) => r.module.chunks)
|
.map((r) => r.module.chunks)
|
||||||
.reduce((a, b) => a.concat(b), [])
|
.reduce((a, b) => a.concat(b), [])
|
||||||
.map((c) => c.name))
|
.map((c) => c.name))
|
||||||
|
|
||||||
const chunkHashes = new Map(
|
const chunkHashes = new Map(
|
||||||
compilation.chunks
|
compilation.chunks
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable import/first, no-return-await */
|
||||||
require('@zeit/source-map-support').install()
|
require('@zeit/source-map-support').install()
|
||||||
import { resolve, join, sep } from 'path'
|
import { resolve, join, sep } from 'path'
|
||||||
import { parse as parseUrl } from 'url'
|
import { parse as parseUrl } from 'url'
|
||||||
|
|
|
@ -198,15 +198,15 @@ function serializeError (dev, err) {
|
||||||
export function serveStatic (req, res, path) {
|
export function serveStatic (req, res, path) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
send(req, path)
|
send(req, path)
|
||||||
.on('directory', () => {
|
.on('directory', () => {
|
||||||
// We don't allow directories to be read.
|
// We don't allow directories to be read.
|
||||||
const err = new Error('No directory access')
|
const err = new Error('No directory access')
|
||||||
err.code = 'ENOENT'
|
err.code = 'ENOENT'
|
||||||
reject(err)
|
reject(err)
|
||||||
})
|
})
|
||||||
.on('error', reject)
|
.on('error', reject)
|
||||||
.pipe(res)
|
.pipe(res)
|
||||||
.on('finish', resolve)
|
.on('finish', resolve)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react'
|
||||||
|
|
||||||
export default class AsyncProps extends React.Component {
|
export default class AsyncProps extends React.Component {
|
||||||
static async getInitialProps () {
|
static async getInitialProps () {
|
||||||
return await fetchData()
|
return fetchData()
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
|
@ -29,7 +29,7 @@ export default (context, render) => {
|
||||||
browser.close()
|
browser.close()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should not show the default HMR error overlay', async() => {
|
it('should not show the default HMR error overlay', async () => {
|
||||||
const browser = await webdriver(context.appPort, '/hmr/about')
|
const browser = await webdriver(context.appPort, '/hmr/about')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('p').text()
|
.elementByCss('p').text()
|
||||||
|
|
|
@ -70,7 +70,7 @@ describe('Custom Server', () => {
|
||||||
expect($dynamic('img').attr('src')).toBe(`http://127.0.0.1:${context.appPort}/static/myimage.png`)
|
expect($dynamic('img').attr('src')).toBe(`http://127.0.0.1:${context.appPort}/static/myimage.png`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should support next/asset in client side', async() => {
|
it('should support next/asset in client side', async () => {
|
||||||
const browser = await webdriver(context.appPort, '/')
|
const browser = await webdriver(context.appPort, '/')
|
||||||
await browser
|
await browser
|
||||||
.elementByCss('#go-asset').click()
|
.elementByCss('#go-asset').click()
|
||||||
|
|
|
@ -65,9 +65,9 @@ describe('Production Usage', () => {
|
||||||
it('should navigate via client side', async () => {
|
it('should navigate via client side', async () => {
|
||||||
const browser = await webdriver(appPort, '/')
|
const browser = await webdriver(appPort, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('a').click()
|
.elementByCss('a').click()
|
||||||
.waitForElementByCss('.about-page')
|
.waitForElementByCss('.about-page')
|
||||||
.elementByCss('div').text()
|
.elementByCss('div').text()
|
||||||
|
|
||||||
expect(text).toBe('About Page')
|
expect(text).toBe('About Page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -98,8 +98,8 @@ describe('Production Usage', () => {
|
||||||
it('should reload the page on page script error', async () => {
|
it('should reload the page on page script error', async () => {
|
||||||
const browser = await webdriver(appPort, '/counter')
|
const browser = await webdriver(appPort, '/counter')
|
||||||
const counter = await browser
|
const counter = await browser
|
||||||
.elementByCss('#increase').click().click()
|
.elementByCss('#increase').click().click()
|
||||||
.elementByCss('#counter').text()
|
.elementByCss('#counter').text()
|
||||||
expect(counter).toBe('Counter: 2')
|
expect(counter).toBe('Counter: 2')
|
||||||
|
|
||||||
// When we go to the 404 page, it'll do a hard reload.
|
// When we go to the 404 page, it'll do a hard reload.
|
||||||
|
@ -120,8 +120,8 @@ describe('Production Usage', () => {
|
||||||
it('should reload the page on page script error with prefetch', async () => {
|
it('should reload the page on page script error with prefetch', async () => {
|
||||||
const browser = await webdriver(appPort, '/counter')
|
const browser = await webdriver(appPort, '/counter')
|
||||||
const counter = await browser
|
const counter = await browser
|
||||||
.elementByCss('#increase').click().click()
|
.elementByCss('#increase').click().click()
|
||||||
.elementByCss('#counter').text()
|
.elementByCss('#counter').text()
|
||||||
expect(counter).toBe('Counter: 2')
|
expect(counter).toBe('Counter: 2')
|
||||||
|
|
||||||
// Let the browser to prefetch the page and error it on the console.
|
// Let the browser to prefetch the page and error it on the console.
|
||||||
|
|
|
@ -7,7 +7,7 @@ export default function (context) {
|
||||||
it('should render the home page', async () => {
|
it('should render the home page', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#home-page p').text()
|
.elementByCss('#home-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('This is the home page')
|
expect(text).toBe('This is the home page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -16,9 +16,9 @@ export default function (context) {
|
||||||
it('should do navigations via Link', async () => {
|
it('should do navigations via Link', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#about-via-link').click()
|
.elementByCss('#about-via-link').click()
|
||||||
.waitForElementByCss('#about-page')
|
.waitForElementByCss('#about-page')
|
||||||
.elementByCss('#about-page p').text()
|
.elementByCss('#about-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('This is the About page')
|
expect(text).toBe('This is the About page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -27,9 +27,9 @@ export default function (context) {
|
||||||
it('should do navigations via Router', async () => {
|
it('should do navigations via Router', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#about-via-router').click()
|
.elementByCss('#about-via-router').click()
|
||||||
.waitForElementByCss('#about-page')
|
.waitForElementByCss('#about-page')
|
||||||
.elementByCss('#about-page p').text()
|
.elementByCss('#about-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('This is the About page')
|
expect(text).toBe('This is the About page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -38,11 +38,11 @@ export default function (context) {
|
||||||
it('should do run client side javascript', async () => {
|
it('should do run client side javascript', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#counter').click()
|
.elementByCss('#counter').click()
|
||||||
.waitForElementByCss('#counter-page')
|
.waitForElementByCss('#counter-page')
|
||||||
.elementByCss('#counter-increase').click()
|
.elementByCss('#counter-increase').click()
|
||||||
.elementByCss('#counter-increase').click()
|
.elementByCss('#counter-increase').click()
|
||||||
.elementByCss('#counter-page p').text()
|
.elementByCss('#counter-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('Counter: 2')
|
expect(text).toBe('Counter: 2')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -51,9 +51,9 @@ export default function (context) {
|
||||||
it('should render pages using getInitialProps', async () => {
|
it('should render pages using getInitialProps', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#get-initial-props').click()
|
.elementByCss('#get-initial-props').click()
|
||||||
.waitForElementByCss('#dynamic-page')
|
.waitForElementByCss('#dynamic-page')
|
||||||
.elementByCss('#dynamic-page p').text()
|
.elementByCss('#dynamic-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('cool dynamic text')
|
expect(text).toBe('cool dynamic text')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -62,9 +62,9 @@ export default function (context) {
|
||||||
it('should render dynamic pages with custom urls', async () => {
|
it('should render dynamic pages with custom urls', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#dynamic-1').click()
|
.elementByCss('#dynamic-1').click()
|
||||||
.waitForElementByCss('#dynamic-page')
|
.waitForElementByCss('#dynamic-page')
|
||||||
.elementByCss('#dynamic-page p').text()
|
.elementByCss('#dynamic-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('next export is nice')
|
expect(text).toBe('next export is nice')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -73,11 +73,11 @@ export default function (context) {
|
||||||
it('should support client side naviagtion', async () => {
|
it('should support client side naviagtion', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#counter').click()
|
.elementByCss('#counter').click()
|
||||||
.waitForElementByCss('#counter-page')
|
.waitForElementByCss('#counter-page')
|
||||||
.elementByCss('#counter-increase').click()
|
.elementByCss('#counter-increase').click()
|
||||||
.elementByCss('#counter-increase').click()
|
.elementByCss('#counter-increase').click()
|
||||||
.elementByCss('#counter-page p').text()
|
.elementByCss('#counter-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('Counter: 2')
|
expect(text).toBe('Counter: 2')
|
||||||
|
|
||||||
|
@ -97,15 +97,15 @@ export default function (context) {
|
||||||
it('should render dynamic import components in the client', async () => {
|
it('should render dynamic import components in the client', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
await browser
|
await browser
|
||||||
.elementByCss('#dynamic-imports-page').click()
|
.elementByCss('#dynamic-imports-page').click()
|
||||||
.waitForElementByCss('#dynamic-imports-page')
|
.waitForElementByCss('#dynamic-imports-page')
|
||||||
|
|
||||||
// Wait until browser loads the dynamic import chunk
|
// Wait until browser loads the dynamic import chunk
|
||||||
// TODO: We may need to find a better way to do this
|
// TODO: We may need to find a better way to do this
|
||||||
await waitFor(5000)
|
await waitFor(5000)
|
||||||
|
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#dynamic-imports-page p').text()
|
.elementByCss('#dynamic-imports-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('Welcome to dynamic imports.')
|
expect(text).toBe('Welcome to dynamic imports.')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -116,9 +116,9 @@ export default function (context) {
|
||||||
|
|
||||||
// Check for the query string content
|
// Check for the query string content
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#with-hash').click()
|
.elementByCss('#with-hash').click()
|
||||||
.waitForElementByCss('#dynamic-page')
|
.waitForElementByCss('#dynamic-page')
|
||||||
.elementByCss('#dynamic-page p').text()
|
.elementByCss('#dynamic-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('zeit is awesome')
|
expect(text).toBe('zeit is awesome')
|
||||||
|
|
||||||
|
@ -139,9 +139,9 @@ export default function (context) {
|
||||||
const browser = await webdriver(context.port, '/button-link')
|
const browser = await webdriver(context.port, '/button-link')
|
||||||
|
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('button').click()
|
.elementByCss('button').click()
|
||||||
.waitForElementByCss('#home-page')
|
.waitForElementByCss('#home-page')
|
||||||
.elementByCss('#home-page p').text()
|
.elementByCss('#home-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('This is the home page')
|
expect(text).toBe('This is the home page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -151,9 +151,9 @@ export default function (context) {
|
||||||
it('should render the home page', async () => {
|
it('should render the home page', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#level1-home-page').click()
|
.elementByCss('#level1-home-page').click()
|
||||||
.waitForElementByCss('#level1-home-page')
|
.waitForElementByCss('#level1-home-page')
|
||||||
.elementByCss('#level1-home-page p').text()
|
.elementByCss('#level1-home-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('This is the Level1 home page')
|
expect(text).toBe('This is the Level1 home page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
@ -162,9 +162,9 @@ export default function (context) {
|
||||||
it('should render the about page', async () => {
|
it('should render the about page', async () => {
|
||||||
const browser = await webdriver(context.port, '/')
|
const browser = await webdriver(context.port, '/')
|
||||||
const text = await browser
|
const text = await browser
|
||||||
.elementByCss('#level1-about-page').click()
|
.elementByCss('#level1-about-page').click()
|
||||||
.waitForElementByCss('#level1-about-page')
|
.waitForElementByCss('#level1-about-page')
|
||||||
.elementByCss('#level1-about-page p').text()
|
.elementByCss('#level1-about-page p').text()
|
||||||
|
|
||||||
expect(text).toBe('This is the Level1 about page')
|
expect(text).toBe('This is the Level1 about page')
|
||||||
browser.close()
|
browser.close()
|
||||||
|
|
|
@ -18,27 +18,27 @@ export default function (context) {
|
||||||
expect(filePathLink).toEqual('/file-name.md')
|
expect(filePathLink).toEqual('/file-name.md')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a page with getInitialProps', async() => {
|
it('should render a page with getInitialProps', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/dynamic')
|
const html = await renderViaHTTP(context.port, '/dynamic')
|
||||||
expect(html).toMatch(/cool dynamic text/)
|
expect(html).toMatch(/cool dynamic text/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render a dynamically rendered custom url page', async() => {
|
it('should render a dynamically rendered custom url page', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/dynamic/one')
|
const html = await renderViaHTTP(context.port, '/dynamic/one')
|
||||||
expect(html).toMatch(/next export is nice/)
|
expect(html).toMatch(/next export is nice/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render pages with dynamic imports', async() => {
|
it('should render pages with dynamic imports', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/dynamic-imports')
|
const html = await renderViaHTTP(context.port, '/dynamic-imports')
|
||||||
expect(html).toMatch(/Welcome to dynamic imports/)
|
expect(html).toMatch(/Welcome to dynamic imports/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should render paths with extensions', async() => {
|
it('should render paths with extensions', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/file-name.md')
|
const html = await renderViaHTTP(context.port, '/file-name.md')
|
||||||
expect(html).toMatch(/this file has an extension/)
|
expect(html).toMatch(/this file has an extension/)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should give empty object for query if there is no query', async() => {
|
it('should give empty object for query if there is no query', async () => {
|
||||||
const html = await renderViaHTTP(context.port, '/get-initial-props-with-no-query')
|
const html = await renderViaHTTP(context.port, '/get-initial-props-with-no-query')
|
||||||
expect(html).toMatch(/Query is: {}/)
|
expect(html).toMatch(/Query is: {}/)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue