Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
github.com/mertingen/stock-api
It has a RESTful API with two endpoints. One of them that fetches the data in the provided MongoDB collection and returns the results in the requested format. Second endpoint is to create(POST) and fetch(GET) data from an Redis database.
You'll see .env.sample in the root directory, you should create .env file next to it and fulfill these variable to initialize the app.
DB_USER=
DB_PASS=
DB_HOST=
DB_NAME=
PORT=
REDIS_USER=
REDIS_PASS=
REDIS_HOST=
REDIS_PORT=
If'd rather run tests file, firstly you need to fufill .env.test file while checking .env.sample file and you'll enter in "tests" directory then run go test
Also, you'll see a todo_list.md file in the repository and it lists the matters that the app should have those feature in the future. Because those matters will make the app better.
The request payload of the first endpoint will include a JSON with 4 fields. ● “startDate” and “endDate” fields will contain the date in a “YYYY-MM-DD” format. You should filter the data using “createdAt” ● “minCount” and “maxCount” are for filtering the data. Sum of the “count” array in the documents should be between “minCount” and “maxCount”.
Response payload should have 3 main fields. ● “code” is for status of the request. 0 means success. Other values may be used for errors that you define. ● “msg” is for description of the code. You can set it to “success” for successful requests. For unsuccessful requests, you should use explanatory messages. ● “records” will include all the filtered items according to the request. This array should include items of “key”, “createdAt” and “totalCount” which is the sum the “counts” array in the document.
localhost:8080/api/v1/records
{
"startDate": "2016-01-26",
"endDate": "2018-02-02",
"minCount": 2700,
"maxCount": 3000
}
The request payload of POST endpoint will include a JSON with 2 fields.
● “key” fields holds the key (any key in string type) ● “value” fields holds the value (any value in string type)
Response payload should return echo of the request or error (if any).
The request payload of GET endpoint will include 1 query parameter. That is “key” param holds the key (any key in string type)
localhost:8080/api/v1/stocks
{
"key": "test-key",
"value": "test-val"
}
localhost:8080/api/v1/stocks?key=test-key
?key=test-key
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.