Challenge Overview
Twine, is an asynchronous (non-live) video chat application in which users can create a base video that other users can interject their own video responses at any point in the video, which is themselves videos that users could interject a video response into.
We have already created the base react-native app & integrated Firebase & Storybook. In this phase we want you to create NodeJS & Serverless RESTful APIs.
Technology Stack
-
React Native
-
CSS/SCSS
-
React Native Web
-
Firebase
-
NodeJS
-
Serverless
General requirements
Code Formatting
-
Make sure code is well documented, all classes, methods, variables, parameters, return values must be documented in every single code file, and appropriate inline comments should be provided too where the code is not straightforward to understand.
-
Please use clean INDENTATION for all the code so future developers can follow the code.
-
Use appropriate linter to validate your code.
JAVASCRIPT SPECIFIC
-
Code written in JavaScript should pass the lint Validation.
LAYOUT
Use the same layout as it’s there in the existing app.
PLATFORM
The app should run on iOS, Android & Web browser (using react-native-web integration)
REFERENCES:
Business Requirements
Resources
Following resources are provided:
-
React-Native App: Attached in the forum.
-
MOCK_DATA.json: Attached in the forum.
API Prefix
All the endpoints should have the common prefix `api/<version>/`
1. Auth
Create the following route:
Endpoint: POST /auth
Response: Auth Token
Description: This route should authenticate a user anonymously using Firebase. Follow the instructions here to crete this https://firebase.google.com/docs/reference/rest/auth#section-sign-in-anonymously
2a. Inbox
Create the following route:
Endpoint: GET /inbox . This route should be secured & should give Authentication error without a valid token.
Response: Inbox data in following format:
{
status: "s/f",
data: "<Array>",
service: "inboxService",
message: "<Error/success msg>"
}
The status can be “S” if data is retrieved successfully otherwise it should be “F”.
Data should contain the list of messages present in the inbox.
Description: This endpoint should retrieve the list of messages present in the inbox. The message should be stored in the Firestore database. The MOCK_DATA.json has been provided in forums. Please use this data only.
You should implement these status codes:
-
200, 401, 500, 503
2b. Inbox/Public
Create the following route:
Endpoint: GET /inbox/public
Just a different name, it should be the same as GET /inbox
2c. Inbox/Yours
Create the following route:
Endpoint: GET /inbox/yours
Just a different name, it should be the same as GET /inbox
3a. Video Upload
Video should be uploaded to the Firebased Storage & on success upload a twine (record) should be created in the Firestore database.
Create the following route using Multer or similar lib to handle multipart/form-data. The upload video file format should be MP4 (Max size 64MB). The Max Size should be configurable in the NodeJS App. Refer this & Firebase Storage for a reference.
Endpoint: POST /twine . This route should be secured & should give Authentication error without a valid token.
Request body:
{
data: fileData,
headers: { 'Content-Type': 'multipart/form-data' },
service: "twineService",
... more
}
Response: Twine data in following format:
{
status: "s/f",
data: "Object (the twine object that’s just created)",
service: "twineService",
message: "<Error/success msg>"
}
The status can be “s” if data is retrieved successfully otherwise it should be “f”.
Data should contain the twine (record) that’s created on successful upload. The data format is specified below.
Data should be empty/null when the upload fails.
When the video upload is successful a twine (record) in the following format should be created in the firestore database & the data field of the response should return this twine:
Twine Data Format
{
id: "<unique_string>",
tiwne_id: "<unique_string>",
author: "system",
title: "lorem ipsum",
likes: 0,
unlikes: 0,
created_at: "<uploaded time in ISO format e.g. 2020-10-04T13:15:30Z>",
is_disabled: false,
is_public: true,
is_published: true,
video_download_url: "<url_of_uploaded_video>",
recipient_ids: "[] <it should be an empty array for now>",
readby_user_ids: "[] <it should be an empty array for now>",
messages: "[] <it should be empty an array for now>",
}
3b. GET /twine/:id
Endpoint: GET /twine/:twine_id . This route should be secured & should give Authentication error without a valid token.
Response:
{
status: "s/f",
data: "Object",
service: "twineService",
message: "<Error/success msg>"
}
The status can be “s” if data is retrieved successfully otherwise it should be “f”.
Data should contain the twine (record) having the requested twine_id. The data format is specified in the Twine Data Format section above.
You should implement these status codes:
-
200, 401, 500, 503
Integration
In the react-native app (snapshot).
-
The Sent to you tab should list the content received from ‘GET /inbox’ API call.
-
The Public tab should list the content received from ‘GET /inbox’ API call.
-
The Yours tab should list the content received from ‘GET /inbox/yours’ API call.
The list-item should appear like this (ignore the layout give app):
The integration of other endpoints is out of scope.
The current react-native app requires to add the configurations & credentials in `config/index.ts`. These configurations should no longer be saved on the client-side (i.e. in the react-native app). Please keep all these configuration settings at the server-side, i.e. in the NodeJS API. You may also need to update firebase-config.ts
Final Submission Guidelines
Submit a zip container containing:
-
Source code of the API
-
Source code of the React Native App
-
Postman collection or Swagger for the API documentation.
-
Readme/Instructions to run the code. You may need to provide the details of your test env to the reviews for testing.