-
Notifications
You must be signed in to change notification settings - Fork 0
AndySpaven/user_limit_test
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
User Limit
==========
A small NodeJS express app to (hopefully) satisfy tech test requirements.
Design Notes
============
1. The streaming could be via a websocket in which case we could roll both connection and "can we stream" into one call to open the socket rather than this simplified API
2. User authentication and authorisation isn't included. Oauth/OpenID Connect would probably be used in reality.
3. User is provided as a part of the URL path params rather more likely as a header containing a JWT from (2) above.
4. Persistence would normally be via a database (SQL or NoSQL - the simplicity of the data makes either suitable). I have chosen instead to use the simplest of in memory structures.
5. Productionisation hasn't been performed so there is
a) No docker or other container files to start a suitable cluster of microservices (separated database and app for example).
b) No transactionality on the counting of streams currently assigned to a user.
c) No reverse proxies to provide HTTPS offloaded from Express server.
d) No load balancers to utilise multiple node instances (this would definitely require a DB).
e) No ELK stack or similar to aggregate logs and monitoring through graphana etc.
6. No swagger to supply automated documentation of endpoints.
7. Should not normally use user name as a key in a database - we'd have a user id from the authentication/authorisation module with which to uniquely identify the user.
8. The calls to user streaming endpoints would validate the user and the stream ids before proceeding and return failure otherwise.
9. There is no DI being used (regarding db and service use).
10. There is no mocking in the tests. Whilst maybe okay for the route tests this is not ideal for the service test for example.
11. The stop streaming route suffered a bug due it being agnostic to whether a stream for the name and id even existed. This should change.
12. No demonstration of promises or promise chaining or of await inside async methods. DB interaction is typically async.
Running the App
===============
Assuptions
----------
You have
1. Node 10.16 or higher installed.
2. npm 6.4.1 or higher installed.
2. Familiarity with git, your OS, npm and curl.
Actions
-------
1. Clone this repository
2. change directory to the folder generated by the cloning
3. Type
npm install
4. Type
npm run dev
visit localhost:3000 in a browser to see the home page to know the server is running.
5. In another terminal :-
Use a mix of the following curl commands to request starting and stopping streams.
(The user name alice and the stream id can be changed as desired).
Start: -
curl "localhost:3000/user/alice/stream/123"
Stop: -
curl -X "DELETE" "localhost:3000/user/alice/stream/123"
Side-Notes
==========
Uplift Express Generator code to ES6 thanks to: -
https://www.freecodecamp.org/news/how-to-enable-es6-and-beyond-syntax-with-node-and-express-68d3e11fe1ab/
About
A simple NodeJS app to satify a submission.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published