Welcome to the backend of the ScholarX project!
ScholarX is an initiative that aims to provide free premium mentoring assistance to elite undergraduate students based in Sri Lanka. The program connects these students with Sri Lankan expatriates currently involved with some of the world's most renowned universities or Fortune 500 companies. The goal is to establish a sustainable education structure within Sri Lanka by leveraging knowledge and expertise from around the globe.
We welcome contributions to make ScholarX even better! Feel free to send us a pull request with your changes or improvements. Check out our Development Best Practices at SEF for guidelines.
Before you can start using this project, make sure you have the following installed on your local machine:
Follow these steps to get started with the ScholarX backend:
Clone this repository to your local machine:
git clone https://github.com/yourusername/scholarx-backend.git
Install the dependencies:
npm install
Copy .env.example
file as .env
:
cp .env.example .env #For Linux and macos
Replace the environment variables in the newly created .env
file with your configurations.
Start the server:
npm start
Run Tests:
npm test
Open your web browser and navigate to http://localhost:${server_port}
to access the running server.
Ensure you have PostgreSQL installed on your machine. If not, you can download it from here.
Create a new PostgreSQL database:
CREATE DATABASE scholarx;
Update your .env
file with your database configuration:
DB_HOST=localhost
DB_PORT=5432
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_NAME=scholarx
Synchronize the database schema:
npm run sync:db
This command synchronizes your database schema with the current state of the entities on your project.
Seed the database
npm run seed
This command builds the project and runs the database seeding script located in dist/src/scripts/seed-db.js
.
To generate a new migration named AddUserTable
:
npm run migration:generate -- -n AddUserTable
To run all pending migrations:
npm run migration:run
To enable Email functionality in this project, follow these steps:
Visit https://console.cloud.google.com
Sign in with your Google account. If you don't have one, you'll need to create one.
Once signed in, you'll be directed to the Google Cloud Console. At the top left of the page, you'll see a drop-down menu with text "Select a Project". Click on this menu.
If you have existing projects, you can select one or click on the "New Project" button.
In the "Project Name" field, give your project a unique name. Then select a location (region) for your project's resources.
Once the details are filled, click the "Create" button at the bottom.
Google Cloud Platform will now create your project. This might take a few moments.
Navigate to the Google Cloud Console. Select your project using the project selector at the top. In the left navigation pane, click on "APIs & Services" and then click on "Library."
Search for "Google+ API" in the library.
Click on the Google+ API and then click the "Enable" button.
Navigate to the API & Services Dashboard: Open the Google Cloud Console. Select your project.
Open the API & Services Dashboard:
In the left navigation pane, click on "APIs & Services" and then click on "Credentials."
Click on "Create Credentials" and choose "OAuth consent screen." Fill in the required details for your OAuth consent screen, such as product name, user support email, and developer contact information.
Navigate to the API & Services Dashboard: In the "Credentials" page, click on "Create Credentials" and choose "OAuth client ID." Configure OAuth Client ID: Select the application type and Enter a name for your client ID. Configure the authorized redirect URIs.
Save Credentials:
Click "Create" to generate your OAuth client ID and client secret.
After obtaining the OAuth client ID and client secret,set the environment variables in your application to use these credentials.
Ex:
process.env.GOOGLE_CLIENT_ID = 'your-client-id'; process.env.GOOGLE_CLIENT_SECRET = 'your-client-secret'; process.env.GOOGLE_REDIRECT_URL = 'your-redirect-uri';
We appreciate your interest in ScholarX. Happy contributing! If you have any questions or need assistance, please don't hesitate to reach out to us.
Create LinkedIn page with the mandatory information.
Navigate to https://developer.linkedin.com/
Select "Create App":
In Products section select Share on LinkedIn
and Sign In with LinkedIn using OpenID Connect
request access.
In Auth section edit the Authorized redirect URLs for your app
and add the redirect url. http://localhost:3000/api/auth/linkedin/callback
Copy Client Id and Client Secret from the Auth Section.
In setting section verify the LinkedIn Page and generate URL.
Verify it from your account.
Here's an overview of the project structure:
scholarx-backend/
├── src/
│ ├── controllers/
│ │ └── index.ts
│ ├── middleware/
│ │ └── index.ts
│ ├── routes/
│ │ └── index.ts
│ ├── services/
│ │ └── auth.service.ts
│ ├── entities/
│ │ └── profile.entity.ts
│ ├── index.ts
│ └── types.ts
├── .env.example
├── .gitignore
├── package.json
├── tsconfig.json
└── README.md
src/controllers/
: Contains the controller classes that handle incoming requests.src/middleware/
: Contains the middleware functions used to modify requests and responses.src/routes/
: Contains the route definitions for the application.src/services/
: Contains the service definitions for the application.src/entities/
: Contains the entity models for the application.src/index.ts
: Creates and configures the Express application and starts the server.src/types.ts
: Defines custom types for the application..env.example
: An example configuration file for environment variables..gitignore
: A list of files and directories to be ignored by Git.package.json
: Contains information about the project and its dependencies.tsconfig.json
: Configuration file for the TypeScript compiler.