-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
65 lines (60 loc) · 1.82 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
const express = require("express");
const app = express();
const ErrorHandler = require("./middlewares/ErrorHandler.mid");
const Anagram = require("./middlewares/anagram.mid");
/**
* @api {get} /find Find Anagrams
* @apiName FindAnagrams
* @apiDescription This endpoint will find all anagrams in the dictionary based on the string sent
* @apiGroup Anagram
* @apiParam (query) {String} word
* @apiExample {curl} Example usage:
* curl -X GET -H "Content-Type: application/json" http://localhost:3001/find?word=test
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* [
* "word1",
* "word2",
* "word3"
* ]
*/
app.get("/find", Anagram.find);
/**
* @api {get} /find-longest Find only the longests Anagrams
* @apiName FindLogestsAnagrams
* @apiDescription This endpoint will find anagrams with the longest size in the dictionary based on the string sent
* @apiGroup Anagram
*
* @apiParam (query) {String} word
*
* @apiExample {curl} Example usage:
* curl -X GET -H "Content-Type: application/json" http://localhost:3001/find?word=test
*
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* [
* "word1",
* "word2",
* "word3"
* ]
*/
app.get("/find-longest", Anagram.findLongest);
/**
* @api {get} /compare Compare Anagrams
* @apiName CompareAnagrams
* @apiDescription This endpoint will receive two words, and compare them to see if they are anagrams
* @apiGroup Anagram
*
* @apiParam (query) {String} word1
* @apiParam (query) {String} word2
*
* @apiExample {curl} Example usage:
* curl -X GET -H "Content-Type: application/json" http://localhost:3001/compare?word1=test&word2=tset
*
* @apiSuccessExample {json} Success-Response:
* HTTP/1.1 200 OK
* false
*/
app.get("/compare", Anagram.compare);
app.use(ErrorHandler);
module.exports = app;