AstroSentinel is an Express.js web application that provides an interactive map displaying light pollution levels. The map showcases markers with SQM measurements and Bortle scale values, allowing users to visualize and contribute to a collective understanding of light pollution.
The directories and files in this project are:
- config/: Contains database configuration files (
db.js
). - models/: Houses Mongoose models for interacting with the database(
users.js
,markers.js
) - routes/: Includes route files, separating different functionalities into modular components.
- views/: Contains the views for rendering the project's front-end(.ejs, .js and .css files)
- server.js: The main entry point of the application.
- package.json and package-lock.json: list of project dependencies and their versions.
The database configuration is handled in the config/db.js
file. This file uses the dotenv
package to load environment variables, including the database connection string. To set up the database configuration:
-
Create an .env file:
-
In the root directory, create a file named
.env
. -
Add the following content, replacing
your_actual_database_url_with_password
with your MongoDB connection string:DB_URL=your_actual_database_url_with_password
-
-
Install dependencies:
-
Run the following command to install the required packages:
npm install
-
-
Start the application:
-
Run the application using the following command:
node server.js
The application should now connect to the database using the provided connection string.
-
To enable OAuth2 authentication in the application, set up the necessary credentials and environment variables.
Setting up Google OAuth2 Credentials:
- Create OAuth2 Credentials:
- Go to the Google Cloud Console, and create a new project if needed.
- Navigate to "APIs & Services" > "Credentials" and create OAuth2 credentials (Client ID and Client Secret) for this project.
- Set up Redirect URI:
- Configure the redirect URI for the application in the OAuth2 credentials.
- Use the appropriate redirect URI based on the environment. For example:
- For local development:
http://localhost:3000/auth/google/callback
- For testing with OAuth2 Playground:
https://developers.google.com/oauthplayground
- For local development:
- Set Environment Variables:
- Add the following environment variables to the
.env
file in the root directory of this project:EMAIL=YOUR_GOOGLE_EMAIL_HERE REFRESH_TOKEN=PASTE_REFRESH_TOKEN_HERE CLIENT_SECRET=PASTE_CLIENT_SECRET_HERE CLIENT_ID=PASTE_CLIENT_ID_HERE AUTH_SESSION_SECRET=PASTE_SESSION_SECRET_HERE JWT_SECRET=PASTE_JWT_SECRET_HERE
- These values can be obtained from Google Developer Console. For more guidance on creating OAuth 2.0 API Credentials, refer to Creating OAuth 2.0 API Credentials.
- Add the following environment variables to the
If you would like to contribute to this project:
- Fork the repository.
- Clone your forked repository to your local machine.
- Set up your local environment by following the steps in the sections above.
- Make changes and improvements.
- Create a pull request to propose your changes.
Ad Astra! π«