Skip to content

Commit

Permalink
Merge pull request #22 from Justkant/cart-creation
Browse files Browse the repository at this point in the history
Cart creation
  • Loading branch information
Justkant committed Nov 27, 2015
2 parents 968a67d + 4c25f97 commit cf687d5
Show file tree
Hide file tree
Showing 48 changed files with 1,014 additions and 301 deletions.
11 changes: 11 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.idea/
.git/
node_modules/
dist/
*.iml
webpack-stats.json
webpack-stats.debug.json
npm-debug.log
rethinkdb_data/
uploads/
doc/
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"import/no-duplicates": 0,
"import/named": 0,
"import/namespace": 0,
"react/no-multi-comp": 0,
"import/no-unresolved": 0,
"import/no-named-as-default": 2,
"jsx-quotes": 2,
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: node_js

node_js:
- "4"
- "5"

sudo: false

Expand Down
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM node:latest
MAINTAINER Quentin Jaccarino <[email protected]>

ADD package.json /tmp/package.json
RUN cd /tmp && npm install
RUN mkdir -p /src && cp -a /tmp/node_modules /src/

WORKDIR /src
ADD . /src

EXPOSE 8000

CMD npm run build && npm run start
25 changes: 22 additions & 3 deletions api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const staticOptions = {};
if (config.isProduction) {
staticOptions.maxAge = '60 days';
}
app.use('/uploads', require('serve-static')('uploads/', staticOptions));
app.use('/uploads', express.static('uploads/', staticOptions));

app.get('/load', users.load);
app.post('/login', users.login);
Expand All @@ -41,6 +41,25 @@ app.route('/users/:id')
.put(users.auth, users.isOwner, users.updateUser)
.delete(users.auth, users.isOwner, users.deleteUser);

app.route('/users/:id/cart')
.get(users.auth, users.isOwner, users.getUserCart)
.post(users.auth, users.isOwner, users.addUserProduct)
.delete(users.auth, users.isOwner, users.deleteUserCart);

app.route('/users/:id/cart/:cartId')
.get(users.auth, users.isOwner, users.getUserCartItem)
.put(users.auth, users.isOwner, users.updateCartItem)
.delete(users.auth, users.isOwner, users.deleteCartItem);

app.route('/users/:id/orders')
.get(users.auth, users.isOwner, users.getUserOrders)
.post(users.auth, users.isOwner, users.validateCart);

app.route('/users/:id/orders/:orderId')
.get(users.auth, users.isOwner, users.getUserOrder)
.put(users.auth, users.isAdmin, users.updateOrder)
.delete(users.auth, users.isAdmin, users.deleteOrder);

app.route('/products')
.get(users.auth, users.isAdmin, products.getProducts)
.post(users.auth, users.isAdmin, products.addProduct);
Expand All @@ -52,7 +71,7 @@ app.route('/products/:id')

app.get('/market', users.auth, products.getMarket);

app.get('/search/:text', products.search);
app.get('/search/:text', users.auth, products.search);

app.post('/picture', users.auth, upload.single('picture'), (req, res) => {
res.json({url: req.file.path});
Expand All @@ -64,7 +83,7 @@ if (config.apiPort) {
console.error(err);
}
console.info('----\n==> 🌎 API is running on port %s', config.apiPort);
console.info('==> 💻 Send requests to http://localhost:%s ', config.apiPort);
console.info('==> 💻 Send requests to http://%s:%s ', config.host, config.apiPort);
});
} else {
console.error('==> ERROR: No PORT environment variable has been specified');
Expand Down
2 changes: 1 addition & 1 deletion api/functions/products.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function addProduct(req, res) {
title: req.body.title,
description: req.body.description,
imageUrl: req.body.imageUrl,
price: 0
price: req.body.price
});

product.save().then(() => {
Expand Down
Loading

0 comments on commit cf687d5

Please sign in to comment.