mirror of
https://github.com/typicode/json-server.git
synced 2025-07-27 20:23:34 +08:00
Fix server
This commit is contained in:
@ -1,3 +1,4 @@
|
|||||||
|
var fs = require('fs')
|
||||||
var express = require('express')
|
var express = require('express')
|
||||||
var cors = require('cors')
|
var cors = require('cors')
|
||||||
var http = require('http')
|
var http = require('http')
|
||||||
@ -17,9 +18,9 @@ server.use(express.urlencoded())
|
|||||||
server.use(express.methodOverride())
|
server.use(express.methodOverride())
|
||||||
|
|
||||||
if (fs.existsSync(process.cwd() + '/public')) {
|
if (fs.existsSync(process.cwd() + '/public')) {
|
||||||
app.use(express.static(process.cwd() + '/public'));
|
server.use(express.static(process.cwd() + '/public'));
|
||||||
} else {
|
} else {
|
||||||
app.use(express.static(path.join(__dirname, './public')));
|
server.use(express.static(path.join(__dirname, './public')));
|
||||||
}
|
}
|
||||||
|
|
||||||
server.use(cors())
|
server.use(cors())
|
||||||
|
@ -52,7 +52,7 @@ describe('Server', function() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe.only('GET /:resource?_start=&_end=', function() {
|
describe('GET /:resource?_start=&_end=', function() {
|
||||||
it('should respond with sliced array', function(done) {
|
it('should respond with sliced array', function(done) {
|
||||||
request(server)
|
request(server)
|
||||||
.get('/comments?_start=1&_end=2')
|
.get('/comments?_start=1&_end=2')
|
||||||
|
Reference in New Issue
Block a user