Skip to content

Commit

Permalink
Add readme file and cleaning up the code
Browse files Browse the repository at this point in the history
- remove .env from .gitignore
- add unique property inside post model
  • Loading branch information
purnimagupta committed Oct 5, 2019
1 parent b612f5d commit 8c2d903
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PORT=4000
MONGOIP=localhost
REDISIP=localhost
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
node_modules/

.env
/src/config.ts
lib
data
Expand Down
78 changes: 77 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
Backend written in nodejs and mongoose for reduxtagram-client.
This is the backend for for reduxtagram-client repo. It's using Nodejs,
MongoDb, TypeScript, bcrypt, express-session, redis-server, aws, multer-s3. This
app is inspired from wesbos redux course.


## Features:
- Sign-up & login
- Upload pics you love!
- Share your post url to receive comments and likes ❤


## Technologies used:

#### Client side
- [React](Create-React-App)
- Redux
- Typescript
- Axios


#### Server side
- Nodejs
- Typescript
- Mongoose
- Redis
- aws-sdk & multer-s3


#### Clound services
- Hosting - AWS
- Storing images - AWS S3


## Steps to install
In order to run the app in browser, you would first require to install NodeJS, Mongodb and Redis

- [NodeJS](https://nodejs.org/en/download/)
- [MongoDB](https://docs.mongodb.com/manual/administration/install-community)
- [Redis](https://redis.io/)

Next, install reduxgram-server and reduxtagram-client.

#### Reduxtagram-server
- `git clobe [email protected]:personal-pooya/reduxtagram-server.git`
- Run `npm install`
- Run `npm start`

Server will get started on port 4000.

#### Reduxtagram-client
- `git clone [email protected]:personal-pooya/reduxtagram-client.git`
- Run `npm install`
- Run `npm start`

This will start the client app on port 3000.


## Alternatively, you can also install it using docker
- Install docker
- Clone both the repos
- build the Images:

For reduxtagram-client repo:
- `docker build -t my-reduxtagram-image .`

For reduxtagram-server repo:
- `docker build -t reduxtagram-server-image .`

Note: These images name should match `image` key inside docker-compose.yml file.

- Last, run `docker-compose up` from reduxtagram-server repo to run all the containers.


### For reduxtagram-server
For any bugs, improvements, or feature requests feel free to create an issue [here](https://github.com/personal-pooya/reduxtagram-server/issues/new) with expected result.

### For reduxragram-client
For any bugs, improvements, or feature requests feel free to create an issue [here](https://github.com/personal-pooya/reduxtagram-client/issues/new) with expected result.
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ services:
container_name: reduxtagram-server-container
image: reduxtagram-server-image
restart: always
build: .
ports:
- "4000:4000"
environment:
Expand All @@ -18,7 +17,6 @@ services:
container_name: my-reduxtagram-container
image: my-reduxtagram-image
restart: always
build: .
ports:
- "3000:3000"

Expand Down
17 changes: 1 addition & 16 deletions src/models/comment-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,8 @@ import Comment from '../interfaces/comment.interface';
let CommentsSchema = new mongoose.Schema({
postId: {type: mongoose.Schema.Types.ObjectId, required: true},
text: {type: String, required: true },
username: {type: String, required: true },
username: {type: String, trim: true, required: true },
createdAt: {type: Date, default: Date.now, required: true},
})
// let CommentsSchema = new mongoose.Schema({
// postId: {type: mongoose.Schema.Types.ObjectId, required: true},
// comments: [
// {
// _id: false,
// text: { type: String, required: true },
// username: { type: String, required: true, unique: true}
// }
// ],
// createdAt: { type: Date, default: Date.now, required: true},
// })


// CommentsSchema.index({"postId": 1});


module.exports = mongoose.model<Comment & mongoose.Document>('Comment', CommentsSchema);
6 changes: 3 additions & 3 deletions src/models/posts-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import Post from '../interfaces/post.interface'

let postSchema = new mongoose.Schema({
// _id: { type: mongoose.Schema.Types.ObjectId, auto: true },
email: {type: String, required: true, trim: true},
email: {type: String, required: true, trim: true, unique: true },
caption: { type: String },
likes: { type: Number, default:0},
likes: { type: Number, default:0 },
display_src: { type: String, required: true },
createdAt: { type: Date, default: Date.now, required: true},
createdAt: { type: Date, default: Date.now, required: true },
})

// postSchema.plugin(mongoose_delete, { deletedAt : true });
Expand Down

0 comments on commit 8c2d903

Please sign in to comment.