Skip to content

Add health-checking endpoint on '/' that always returns 200 #2992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/PublicAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
4 changes: 3 additions & 1 deletion src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,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 });
Expand Down Expand Up @@ -286,6 +286,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 }));
Expand Down