The main API used for Leetcode Roulette.
API hosted at https://api.leetcoderoulette.com
To get started running the Leetcode Roulette APIs locally, clone the repository to your local machine and change to the project root directory. Next, make sure to make the needed configurations and run npm install
to get the needed packages for the project. Next, build and run the project with npm run build
followed by npm start
respectively.
git clone https://github.com/leetcode-roulette/gateway-api.git
cd gateway-api
npm install
npm run build
npm start
This will install the required dependencies on your local machine followed by building the source code to a dist
folder and running the server code in the dist/index.js
file.
Before running the Leetcode Roulette APIs locally, the following steps will need to be taken to ensure the needed software will be installed or set up.
- Install npm and NodeJS
- Install MongoDB or MongoDB Atlas and setup using the provided instructions
- Follow the instructions in the leetcode-roulette/problem-extractor service to populate the database with the needed resources.
Before starting, you'll need to configure the mongoose database connection string. This can be done by creating a .env
file in the root directory of the project. In the .env
file, be sure to specify a connection string named MONGO_CONNECTION_STRING
.
- MONGO_CONNECTION_STRING: "mongodb://localhost:27017/myDB"
To begin development on this project, clone the repository to your local machine and change to the project root directory. Next, make sure to make the needed configurations and run npm install
to get the needed packages for the project. Finally, run the npm run dev
command to deploy a local development environment on your local machine.
git clone https://github.com/leetcode-roulette/gateway-api.git
cd gateway-api
npm install
npm run dev
This will spin up a nodemon server using the server code in the src/index.ts
file.
To build the project, run the npm run build
command.
npm run build
This will compile the typescript in the src
folder and create a new dist
folder consisting of built Javascript code.
To test the project, run the npm run test
command.
npm run test
This will run the tests in any file in the src
directory following the specified formats.
"**/tests/**/*.spec.ts"
"**/tests/**/*.test.ts"
This project allows users to retrieve problems and tags from leetcode.
The following configurations can be specified in a .env
file.
Type: String
Default: None
Specifies mongodb database uri for mongoose to connect to.
mongoose.connect(MONGO_CONNECTION_STRING); // Connects to the provided uri
Type: Integer
Default: 3000
Specifies which port the server will run on.
app.listen(PORT, () => {
logger.info(`Server is listening on port ${PORT}`); // Log the port the application is being run on
});
Type: String
Default: '1.0.0'
Specifies the current version of the project.
Type: String
Default: 'dev'
Specifies the environment that is being used.
res.status(200).json({
version: VERSION,
environment: ENVIRONMENT,
status: "Live"
});
- NodeJS - Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser.
- MongoDB - MongoDB is a source-available cross-platform document-oriented database program.
- Express.JS - Express.js, or simply Express, is a back end web application framework for Node.js, released as free and open-source software under the MIT License.
- Typescript - TypeScript is a free and open source programming language developed and maintained by Microsoft.