Skip to content

Commit

Permalink
Update local file
Browse files Browse the repository at this point in the history
zhuming15 committed Jun 30, 2023
2 parents 0ae36b6 + 70d08bd commit 57d4841
Showing 2,759 changed files with 190,652 additions and 335 deletions.
1 change: 1 addition & 0 deletions Orbital
Submodule Orbital added at 13e1ab
3 changes: 3 additions & 0 deletions project/my-project-name/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions project/my-project-name/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions project/my-project-name/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions project/my-project-name/.idea/my-project-name.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions project/my-project-name/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions project/my-project-name/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=mysql://root:password@localhost:3002/orbital
3 changes: 0 additions & 3 deletions project/my-project-name/backend/api/admin.py

This file was deleted.

5 changes: 0 additions & 5 deletions project/my-project-name/backend/api/apps.py

This file was deleted.

9 changes: 0 additions & 9 deletions project/my-project-name/backend/api/models.py

This file was deleted.

8 changes: 0 additions & 8 deletions project/my-project-name/backend/api/serializers.py

This file was deleted.

3 changes: 0 additions & 3 deletions project/my-project-name/backend/api/tests.py

This file was deleted.

8 changes: 0 additions & 8 deletions project/my-project-name/backend/api/views.py

This file was deleted.

Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
120 changes: 0 additions & 120 deletions project/my-project-name/backend/backend/settings.py

This file was deleted.

21 changes: 0 additions & 21 deletions project/my-project-name/backend/backend/urls.py

This file was deleted.

16 changes: 0 additions & 16 deletions project/my-project-name/backend/backend/wsgi.py

This file was deleted.

26 changes: 26 additions & 0 deletions project/my-project-name/backend/config/planetscale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const mysql = require('mysql2');

// Creating a connection
const planetscale = mysql.createConnection({
host: 'aws.connect.psdb.cloud',
user: 'lh8dzd33eoy0mrlf5jx3',
password: 'pscale_pw_zhDbFsY97GESqb678oAtusj0URcj1Ne621LNXaZTjSI',
database: 'orbital',
ssl: { rejectUnauthorized: true },
multipleStatements: true,
});

// Connecting to the database
planetscale.connect((err) => {
if (err) {
console.error('Error connecting to the database:', err);
return;
}

console.log('Connected to the database!');

// Closing the connection
// planetscale.end();
});

module.exports = planetscale;
Binary file removed project/my-project-name/backend/db.sqlite3
Binary file not shown.
57 changes: 57 additions & 0 deletions project/my-project-name/backend/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const express = require('express');
const planetscale = require('./config/planetscale');
const cors = require('cors');

const app = express();

const PORT = 3002;
app.use(cors());
app.use(express.json());

// Route for creating the user
app.post('/api/signup', (req, res) => {
const email = req.body.email;
const username = req.body.username;
const password = req.body.password;
const query = "INSERT INTO users (email, username, password_hash) VALUES (?,?,?)";

planetscale.query(query, [email, username, password], (err, result) => {
if (err) {
return res.status(500).json({ error: 'Account already exists' });
}
return res.status(200).json({ message: 'Signup successful' });
});
});

// Route for login
app.post('/api/login', (req, res) => {
const email = req.body.email;
const password = req.body.password;
const query = `SELECT * FROM users WHERE email = ?`;

planetscale.query(query, email, (err, result) => {
if (!data || data.length === 0) {
return res.status(404).json({ error: 'Invalid email or password' });
} else if (result[0].password_hash !== password) {
return res.status(401).json({ error: 'Invalid email or password' });
}
return res.status(200).json({ message: 'Login successful' });
});
});

// Route for deleting account
app.post('/api/delete-account', (req, res) => {
const email = req.body.email;
const query = `DELETE FROM users WHERE email = ?`;

planetscale.query(query, email, (err, result) => {
if (err) {
return res.status(500).json({ error: 'An error occurred while deleting the account' });
}
return res.status(200).json({ message: 'Account deleted successfully' });
});
});

app.listen(PORT, () => {
console.log(`Server is running on ${PORT}`);
});
21 changes: 0 additions & 21 deletions project/my-project-name/backend/manage.py

This file was deleted.

12 changes: 12 additions & 0 deletions project/my-project-name/backend/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions project/my-project-name/backend/node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 57d4841

Please sign in to comment.