Add health-checking endpoint on '/health' that always returns 200 (#2992)
* Add health-checker endpoint on '/health' that always returns 200OK * Refactor health handler, add tests * Refactor health test
This commit is contained in:
committed by
Florent Vilmart
parent
b347bff641
commit
908c48098a
@@ -41,7 +41,7 @@ describe("public API without publicServerURL", () => {
|
||||
beforeEach(done => {
|
||||
reconfigureServer({ appName: 'unused' })
|
||||
.then(done, fail);
|
||||
})
|
||||
});
|
||||
it("should get 404 on verify_email", (done) => {
|
||||
request('http://localhost:8378/1/apps/test/verify_email', (err, httpResponse, body) => {
|
||||
expect(httpResponse.statusCode).toBe(404);
|
||||
|
||||
@@ -164,6 +164,15 @@ describe('server', () => {
|
||||
})
|
||||
});
|
||||
|
||||
it('can respond 200 on path health', done => {
|
||||
request.get({
|
||||
url: 'http://localhost:8378/1/health',
|
||||
}, (error, response, body) => {
|
||||
expect(response.statusCode).toBe(200);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('can create a parse-server v1', done => {
|
||||
var parseServer = new ParseServer.default(Object.assign({},
|
||||
defaultConfiguration, {
|
||||
|
||||
@@ -154,7 +154,7 @@ class ParseServer {
|
||||
}
|
||||
|
||||
if (!filesAdapter && !databaseURI) {
|
||||
throw 'When using an explicit database adapter, you must also use and explicit filesAdapter.';
|
||||
throw 'When using an explicit database adapter, you must also use an explicit filesAdapter.';
|
||||
}
|
||||
|
||||
const loggerControllerAdapter = loadAdapter(loggerAdapter, WinstonLoggerAdapter, { jsonLogs, logsFolder, verbose, logLevel, silent });
|
||||
@@ -288,6 +288,8 @@ class ParseServer {
|
||||
maxUploadSize: maxUploadSize
|
||||
}));
|
||||
|
||||
api.use('/health', (req, res) => res.sendStatus(200));
|
||||
|
||||
api.use('/', bodyParser.urlencoded({extended: false}), new PublicAPIRouter().expressRouter());
|
||||
|
||||
api.use(bodyParser.json({ 'type': '*/*' , limit: maxUploadSize }));
|
||||
|
||||
Reference in New Issue
Block a user