Skip to content

Commit 908c480

Browse files
woyorusflovilmart
authored andcommitted
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
1 parent b347bff commit 908c480

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

spec/PublicAPI.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe("public API without publicServerURL", () => {
4141
beforeEach(done => {
4242
reconfigureServer({ appName: 'unused' })
4343
.then(done, fail);
44-
})
44+
});
4545
it("should get 404 on verify_email", (done) => {
4646
request('http://localhost:8378/1/apps/test/verify_email', (err, httpResponse, body) => {
4747
expect(httpResponse.statusCode).toBe(404);

spec/index.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,15 @@ describe('server', () => {
164164
})
165165
});
166166

167+
it('can respond 200 on path health', done => {
168+
request.get({
169+
url: 'http://localhost:8378/1/health',
170+
}, (error, response, body) => {
171+
expect(response.statusCode).toBe(200);
172+
done();
173+
});
174+
});
175+
167176
it('can create a parse-server v1', done => {
168177
var parseServer = new ParseServer.default(Object.assign({},
169178
defaultConfiguration, {

src/ParseServer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ class ParseServer {
154154
}
155155

156156
if (!filesAdapter && !databaseURI) {
157-
throw 'When using an explicit database adapter, you must also use and explicit filesAdapter.';
157+
throw 'When using an explicit database adapter, you must also use an explicit filesAdapter.';
158158
}
159159

160160
const loggerControllerAdapter = loadAdapter(loggerAdapter, WinstonLoggerAdapter, { jsonLogs, logsFolder, verbose, logLevel, silent });
@@ -288,6 +288,8 @@ class ParseServer {
288288
maxUploadSize: maxUploadSize
289289
}));
290290

291+
api.use('/health', (req, res) => res.sendStatus(200));
292+
291293
api.use('/', bodyParser.urlencoded({extended: false}), new PublicAPIRouter().expressRouter());
292294

293295
api.use(bodyParser.json({ 'type': '*/*' , limit: maxUploadSize }));

0 commit comments

Comments
 (0)