-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5605f0b
Showing
21 changed files
with
6,660 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
node_modules | ||
bundle.js | ||
bundle.js.map | ||
secrets.js | ||
**/resources/static/assets/tmp | ||
**/resources/static/assets/uploads | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# myDiary | ||
|
||
Diary based website that utilizes Artificial Intelligence to detect the sentiment analysis of the user’s diary entry. This project used Node.js, Express, PostgreSQL, and Sequelize. | ||
|
||
## Get Started | ||
|
||
To run this application: | ||
|
||
1. In your terminal type `git clone https://github.com/Ali-Aftab/myDiary.git` to clone it to your computer. | ||
2. Then type `cd myDiary` to access the folder | ||
3. To install the required modules type `npm i` | ||
4. Make a new PostgreSQL database by writing `createdb myDiary` | ||
5. Create a .env file by typing `touch .env` to store your secret keys | ||
6. In the .env file type `SECRET_JWT_KEY=ENTERYOURKEYHERE` | ||
7. Type `npm run start-dev` in your terminal and you can use the API! | ||
|
||
## API | ||
|
||
First, we recommend installing [Postman](https://www.postman.com/) to easily test out the API. Remember to add `localhost:8000` to the URL before typing in the API path. (`/api/auth/signup`=>`localhost:8000/api/signup`) | ||
|
||
### Sign Up/ Login Routes | ||
|
||
How to signup and login. | ||
|
||
- POST `/api/auth/signup` allows anyone to make an account <br/> | ||
-Requires an email and password key inside the body <br/> | ||
-Example {email: [email protected], password: password1} <br/> | ||
- POST `/api/auth/signin` when logged in, the response will give the user an access token. The access token must be placed in the header (with "x-access-token" as the key and the given accessToken as the value) | ||
-Requires an email and password key inside the body. Also the x-access-token inside the header.<br/> | ||
-The x-access-token lasts for 24 hours. <br/> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import Main from "./main"; | ||
|
||
ReactDOM.render( | ||
<div> | ||
<Main /> | ||
</div>, | ||
document.getElementById("app") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react"; | ||
|
||
export default function main() { | ||
const [isLoggedIn, setIsLoggedIn] = useState(false); | ||
return ( | ||
<div> | ||
<h1>Hi</h1> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const path = require("path"); | ||
const express = require("express"); | ||
const app = express(); | ||
const { db, User } = require("./server/db"); | ||
const PORT = process.env.PORT || 8000; | ||
// const seed = require('./seed.js'); | ||
global.__basedir = __dirname; | ||
require("dotenv").config(); | ||
|
||
//--------------------->Body parser <---------------------// | ||
const bodyParser = require("body-parser"); | ||
app.use(bodyParser.json()); | ||
app.use( | ||
bodyParser.urlencoded({ | ||
extended: true, | ||
}) | ||
); | ||
|
||
//--------------------->Loggin middleware morgan https://github.com/expressjs/morgan <---------------------// | ||
const morgan = require("morgan"); | ||
app.use(morgan("dev")); | ||
|
||
//--------------------->Serving javascript files, css files, and images from public folder<---------------------// | ||
//https://expressjs.com/en/starter/static-files.html | ||
|
||
// static file-serving middleware | ||
app.use(express.static(path.join(__dirname, ".", "public"))); | ||
|
||
// API routes are prefixed with /api/ - | ||
// this is purely done to namespace them away from your "front-end routes" (such as those created by react-router). | ||
// app.use("/api", require("./server/apiRoutes")); // matches all requests to /api | ||
require("./server/routes/auth.route")(app); | ||
require("./server/routes/user.route")(app); | ||
|
||
app.get("*", function (req, res, next) { | ||
res.sendFile(path.join(__dirname, "./public/index.html")); | ||
}); | ||
app.use(function (err, req, res, next) { | ||
console.error(err); | ||
console.error(err.stack); | ||
res.status(err.status || 500).send(err.message || "Internal server error."); | ||
}); | ||
|
||
//--------------------->Starting server<--------------------- // | ||
|
||
const startServer = () => { | ||
const server = app.listen(process.env.PORT || PORT, () => | ||
console.log(`Listening on ${PORT}`) | ||
); | ||
}; | ||
(async () => { | ||
await db.sync({}); | ||
console.log("db sync"); | ||
})(startServer()); |
Oops, something went wrong.