├── .editorconfig ├── .env.example ├── .eslintignore ├── .eslintrc ├── .gitignore ├── README.md ├── config ├── admin.js ├── api.js ├── database.js ├── env │ └── production │ │ ├── database.js │ │ └── server.js ├── middlewares.js ├── plugins.js └── server.js ├── database └── migrations │ └── .gitkeep ├── favicon.png ├── package-lock.json ├── package.json ├── public ├── robots.txt └── uploads │ └── .gitkeep ├── server ├── .eslintrc ├── config │ ├── admin.js │ ├── api.js │ ├── database.js │ ├── middlewares.js │ ├── plugins.js │ └── server.js └── database │ └── migrations │ └── .gitkeep └── src ├── admin ├── app.example.js └── webpack.config.example.js ├── api ├── .gitkeep ├── category │ ├── content-types │ │ └── category │ │ │ └── schema.json │ ├── controllers │ │ └── category.js │ ├── routes │ │ └── category.js │ └── services │ │ └── category.js ├── order │ ├── content-types │ │ └── order │ │ │ └── schema.json │ ├── controllers │ │ └── order.js │ ├── routes │ │ ├── custom-router.js │ │ └── order.js │ └── services │ │ └── order.js └── product │ ├── content-types │ └── product │ │ └── schema.json │ ├── controllers │ └── product.js │ ├── routes │ └── product.js │ └── services │ └── product.js ├── extensions └── .gitkeep └── index.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [{package.json,*.yml}] 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | HOST=0.0.0.0 2 | PORT=1337 3 | APP_KEYS="toBeModified1,toBeModified2" 4 | API_TOKEN_SALT=tobemodified 5 | ADMIN_JWT_SECRET=tobemodified 6 | JWT_SECRET=tobemodified 7 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | .cache 2 | build 3 | **/node_modules/** 4 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": "eslint:recommended", 4 | "env": { 5 | "commonjs": true, 6 | "es6": true, 7 | "node": true, 8 | "browser": false 9 | }, 10 | "parserOptions": { 11 | "ecmaFeatures": { 12 | "experimentalObjectRestSpread": true, 13 | "jsx": false 14 | }, 15 | "sourceType": "module" 16 | }, 17 | "globals": { 18 | "strapi": true 19 | }, 20 | "rules": { 21 | "indent": ["error", 2, { "SwitchCase": 1 }], 22 | "linebreak-style": ["error", "unix"], 23 | "no-console": 0, 24 | "quotes": ["error", "single"], 25 | "semi": ["error", "always"] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ############################ 2 | # OS X 3 | ############################ 4 | 5 | .DS_Store 6 | .AppleDouble 7 | .LSOverride 8 | Icon 9 | .Spotlight-V100 10 | .Trashes 11 | ._* 12 | 13 | 14 | ############################ 15 | # Linux 16 | ############################ 17 | 18 | *~ 19 | 20 | 21 | ############################ 22 | # Windows 23 | ############################ 24 | 25 | Thumbs.db 26 | ehthumbs.db 27 | Desktop.ini 28 | $RECYCLE.BIN/ 29 | *.cab 30 | *.msi 31 | *.msm 32 | *.msp 33 | 34 | 35 | ############################ 36 | # Packages 37 | ############################ 38 | 39 | *.7z 40 | *.csv 41 | *.dat 42 | *.dmg 43 | *.gz 44 | *.iso 45 | *.jar 46 | *.rar 47 | *.tar 48 | *.zip 49 | *.com 50 | *.class 51 | *.dll 52 | *.exe 53 | *.o 54 | *.seed 55 | *.so 56 | *.swo 57 | *.swp 58 | *.swn 59 | *.swm 60 | *.out 61 | *.pid 62 | 63 | 64 | ############################ 65 | # Logs and databases 66 | ############################ 67 | 68 | .tmp 69 | *.log 70 | *.sql 71 | *.sqlite 72 | *.sqlite3 73 | 74 | 75 | ############################ 76 | # Misc. 77 | ############################ 78 | 79 | *# 80 | ssl 81 | .idea 82 | nbproject 83 | public/uploads/* 84 | !public/uploads/.gitkeep 85 | 86 | ############################ 87 | # Node.js 88 | ############################ 89 | 90 | lib-cov 91 | lcov.info 92 | pids 93 | logs 94 | results 95 | node_modules 96 | .node_history 97 | 98 | ############################ 99 | # Tests 100 | ############################ 101 | 102 | testApp 103 | coverage 104 | 105 | ############################ 106 | # Strapi 107 | ############################ 108 | 109 | .env 110 | license.txt 111 | exports 112 | *.cache 113 | dist 114 | build 115 | .strapi-updater.json 116 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🚀 Getting started with Strapi 2 | 3 | Strapi comes with a full featured [Command Line Interface](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html) (CLI) which lets you scaffold and manage your project in seconds. 4 | 5 | ### `develop` 6 | 7 | Start your Strapi application with autoReload enabled. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-develop) 8 | 9 | ``` 10 | npm run develop 11 | # or 12 | yarn develop 13 | ``` 14 | 15 | ### `start` 16 | 17 | Start your Strapi application with autoReload disabled. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-start) 18 | 19 | ``` 20 | npm run start 21 | # or 22 | yarn start 23 | ``` 24 | 25 | ### `build` 26 | 27 | Build your admin panel. [Learn more](https://docs.strapi.io/developer-docs/latest/developer-resources/cli/CLI.html#strapi-build) 28 | 29 | ``` 30 | npm run build 31 | # or 32 | yarn build 33 | ``` 34 | 35 | ## ⚙️ Deployment 36 | 37 | Strapi gives you many possible deployment options for your project. Find the one that suits you on the [deployment section of the documentation](https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/deployment.html). 38 | 39 | ## 📚 Learn more 40 | 41 | - [Resource center](https://strapi.io/resource-center) - Strapi resource center. 42 | - [Strapi documentation](https://docs.strapi.io) - Official Strapi documentation. 43 | - [Strapi tutorials](https://strapi.io/tutorials) - List of tutorials made by the core team and the community. 44 | - [Strapi blog](https://docs.strapi.io) - Official Strapi blog containing articles made by the Strapi team and the community. 45 | - [Changelog](https://strapi.io/changelog) - Find out about the Strapi product updates, new features and general improvements. 46 | 47 | Feel free to check out the [Strapi GitHub repository](https://github.com/strapi/strapi). Your feedback and contributions are welcome! 48 | 49 | ## ✨ Community 50 | 51 | - [Discord](https://discord.strapi.io) - Come chat with the Strapi community including the core team. 52 | - [Forum](https://forum.strapi.io/) - Place to discuss, ask questions and find answers, show your Strapi project and get feedback or just talk with other Community members. 53 | - [Awesome Strapi](https://github.com/strapi/awesome-strapi) - A curated list of awesome things related to Strapi. 54 | 55 | --- 56 | 57 | 🤫 Psst! [Strapi is hiring](https://strapi.io/careers). 58 | -------------------------------------------------------------------------------- /config/admin.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | auth: { 3 | secret: env('ADMIN_JWT_SECRET'), 4 | }, 5 | apiToken: { 6 | salt: env('API_TOKEN_SALT'), 7 | }, 8 | }); 9 | -------------------------------------------------------------------------------- /config/api.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rest: { 3 | defaultLimit: 25, 4 | maxLimit: 100, 5 | withCount: true, 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /config/database.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = ({ env }) => ({ 4 | connection: { 5 | client: 'sqlite', 6 | connection: { 7 | filename: path.join(__dirname, '..', env('DATABASE_FILENAME', '.tmp/data.db')), 8 | }, 9 | useNullAsDefault: true, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /config/env/production/database.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | connection: { 3 | client: 'postgres', 4 | connection: { 5 | host: env('DATABASE_HOST'), 6 | port: env.int('DATABASE_PORT'), 7 | database: env('DATABASE_NAME'), 8 | user: env('DATABASE_USERNAME'), 9 | password: env('DATABASE_PASSWORD'), 10 | ssl: { 11 | rejectUnauthorized:env.bool('DATABASE_SSL_SELF', false), 12 | }, 13 | }, 14 | debug: false, 15 | }, 16 | }); 17 | -------------------------------------------------------------------------------- /config/env/production/server.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | proxy: true, 3 | url: env('APP_URL'), // replaces `host` and `port` properties in the development environment 4 | app: { 5 | keys: env.array('APP_KEYS') 6 | }, 7 | }); -------------------------------------------------------------------------------- /config/middlewares.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | 'strapi::errors', 3 | 'strapi::security', 4 | 'strapi::cors', 5 | 'strapi::poweredBy', 6 | 'strapi::logger', 7 | 'strapi::query', 8 | 'strapi::body', 9 | 'strapi::session', 10 | 'strapi::favicon', 11 | 'strapi::public', 12 | ]; 13 | -------------------------------------------------------------------------------- /config/plugins.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | upload: { 3 | config: { 4 | provider: 'cloudinary', 5 | providerOptions: { 6 | cloud_name: env('CLOUDINARY_NAME'), 7 | api_key: env('CLOUDINARY_KEY'), 8 | api_secret: env('CLOUDINARY_SECRET'), 9 | }, 10 | actionOptions: { 11 | upload: {}, 12 | delete: {}, 13 | }, 14 | }, 15 | }, 16 | }); -------------------------------------------------------------------------------- /config/server.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | host: env('HOST', '0.0.0.0'), 3 | port: env.int('PORT', 1337), 4 | app: { 5 | keys: env.array('APP_KEYS'), 6 | }, 7 | }); 8 | -------------------------------------------------------------------------------- /database/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingshuttle/fswd-22-ecommerce-strapi-server/8aa7d3b92f32b18428faaf5c0cc27105ab656551/database/migrations/.gitkeep -------------------------------------------------------------------------------- /favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingshuttle/fswd-22-ecommerce-strapi-server/8aa7d3b92f32b18428faaf5c0cc27105ab656551/favicon.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "private": true, 4 | "version": "0.1.0", 5 | "description": "A Strapi application", 6 | "scripts": { 7 | "develop": "strapi develop", 8 | "start": "strapi start", 9 | "build": "strapi build", 10 | "strapi": "strapi" 11 | }, 12 | "dependencies": { 13 | "@strapi/plugin-i18n": "4.5.6", 14 | "@strapi/plugin-users-permissions": "4.5.6", 15 | "@strapi/provider-upload-cloudinary": "^4.5.6", 16 | "@strapi/strapi": "4.5.6", 17 | "better-sqlite3": "7.4.6", 18 | "pg": "^8.9.0", 19 | "stripe": "^11.8.0" 20 | }, 21 | "author": { 22 | "name": "A Strapi developer" 23 | }, 24 | "strapi": { 25 | "uuid": "951efdd8-9667-4666-a6fb-e8d46e03edec" 26 | }, 27 | "engines": { 28 | "node": ">=14.19.1 <=18.x.x", 29 | "npm": ">=6.0.0" 30 | }, 31 | "license": "MIT" 32 | } 33 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # To prevent search engines from seeing the site altogether, uncomment the next two lines: 2 | # User-Agent: * 3 | # Disallow: / 4 | -------------------------------------------------------------------------------- /public/uploads/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingshuttle/fswd-22-ecommerce-strapi-server/8aa7d3b92f32b18428faaf5c0cc27105ab656551/public/uploads/.gitkeep -------------------------------------------------------------------------------- /server/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": "eslint:recommended", 4 | "env": { 5 | "commonjs": true, 6 | "es6": true, 7 | "node": true, 8 | "browser": false 9 | }, 10 | "parserOptions": { 11 | "ecmaFeatures": { 12 | "experimentalObjectRestSpread": true, 13 | "jsx": false 14 | }, 15 | "sourceType": "module" 16 | }, 17 | "globals": { 18 | "strapi": true 19 | }, 20 | "rules": { 21 | "indent": ["error", 2, { "SwitchCase": 1 }], 22 | "linebreak-style": ["error", "unix"], 23 | "no-console": 0, 24 | "quotes": ["error", "single"], 25 | "semi": ["error", "always"] 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /server/config/admin.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | auth: { 3 | secret: env('ADMIN_JWT_SECRET'), 4 | }, 5 | apiToken: { 6 | salt: env('API_TOKEN_SALT'), 7 | }, 8 | }); 9 | -------------------------------------------------------------------------------- /server/config/api.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | rest: { 3 | defaultLimit: 25, 4 | maxLimit: 100, 5 | withCount: true, 6 | }, 7 | }; 8 | -------------------------------------------------------------------------------- /server/config/database.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = ({ env }) => ({ 4 | connection: { 5 | client: 'sqlite', 6 | connection: { 7 | filename: path.join(__dirname, '..', env('DATABASE_FILENAME', '.tmp/data.db')), 8 | }, 9 | useNullAsDefault: true, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /server/config/middlewares.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | 'strapi::errors', 3 | { 4 | name: 'strapi::security', 5 | config: { 6 | contentSecurityPolicy: { 7 | useDefaults: true, 8 | directives: { 9 | 'connect-src': ["'self'", 'https:'], 10 | 'img-src': ["'self'", 'data:', 'blob:', 'res.cloudinary.com'], 11 | 'media-src': ["'self'", 'data:', 'blob:', 'res.cloudinary.com'], 12 | upgradeInsecureRequests: null, 13 | }, 14 | }, 15 | }, 16 | }, 17 | 'strapi::cors', 18 | 'strapi::poweredBy', 19 | 'strapi::logger', 20 | 'strapi::query', 21 | 'strapi::body', 22 | 'strapi::session', 23 | 'strapi::favicon', 24 | 'strapi::public', 25 | ]; 26 | -------------------------------------------------------------------------------- /server/config/plugins.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | // ... 3 | upload: { 4 | config: { 5 | provider: 'cloudinary', 6 | providerOptions: { 7 | cloud_name: env('CLOUDINARY_NAME'), 8 | api_key: env('CLOUDINARY_KEY'), 9 | api_secret: env('CLOUDINARY_SECRET'), 10 | }, 11 | actionOptions: { 12 | upload: {}, 13 | delete: {}, 14 | }, 15 | }, 16 | }, 17 | // ... 18 | }); -------------------------------------------------------------------------------- /server/config/server.js: -------------------------------------------------------------------------------- 1 | module.exports = ({ env }) => ({ 2 | host: env('HOST', '0.0.0.0'), 3 | port: env.int('PORT', 1337), 4 | app: { 5 | keys: env.array('APP_KEYS'), 6 | }, 7 | }); 8 | -------------------------------------------------------------------------------- /server/database/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingshuttle/fswd-22-ecommerce-strapi-server/8aa7d3b92f32b18428faaf5c0cc27105ab656551/server/database/migrations/.gitkeep -------------------------------------------------------------------------------- /src/admin/app.example.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | locales: [ 3 | // 'ar', 4 | // 'fr', 5 | // 'cs', 6 | // 'de', 7 | // 'dk', 8 | // 'es', 9 | // 'he', 10 | // 'id', 11 | // 'it', 12 | // 'ja', 13 | // 'ko', 14 | // 'ms', 15 | // 'nl', 16 | // 'no', 17 | // 'pl', 18 | // 'pt-BR', 19 | // 'pt', 20 | // 'ru', 21 | // 'sk', 22 | // 'sv', 23 | // 'th', 24 | // 'tr', 25 | // 'uk', 26 | // 'vi', 27 | // 'zh-Hans', 28 | // 'zh', 29 | ], 30 | }; 31 | 32 | const bootstrap = (app) => { 33 | console.log(app); 34 | }; 35 | 36 | export default { 37 | config, 38 | bootstrap, 39 | }; 40 | -------------------------------------------------------------------------------- /src/admin/webpack.config.example.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* eslint-disable no-unused-vars */ 4 | module.exports = (config, webpack) => { 5 | // Note: we provide webpack above so you should not `require` it 6 | // Perform customizations to webpack config 7 | // Important: return the modified config 8 | return config; 9 | }; 10 | -------------------------------------------------------------------------------- /src/api/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingshuttle/fswd-22-ecommerce-strapi-server/8aa7d3b92f32b18428faaf5c0cc27105ab656551/src/api/.gitkeep -------------------------------------------------------------------------------- /src/api/category/content-types/category/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "collectionType", 3 | "collectionName": "categories", 4 | "info": { 5 | "singularName": "category", 6 | "pluralName": "categories", 7 | "displayName": "Category" 8 | }, 9 | "options": { 10 | "draftAndPublish": true 11 | }, 12 | "pluginOptions": {}, 13 | "attributes": { 14 | "title": { 15 | "type": "string", 16 | "required": true, 17 | "unique": true 18 | }, 19 | "key": { 20 | "type": "uid", 21 | "targetField": "title" 22 | }, 23 | "image": { 24 | "allowedTypes": [ 25 | "images" 26 | ], 27 | "type": "media", 28 | "multiple": false 29 | }, 30 | "products": { 31 | "type": "relation", 32 | "relation": "oneToMany", 33 | "target": "api::product.product", 34 | "mappedBy": "category" 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/api/category/controllers/category.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * category controller 5 | */ 6 | 7 | const { createCoreController } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreController('api::category.category'); 10 | -------------------------------------------------------------------------------- /src/api/category/routes/category.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * category router 5 | */ 6 | 7 | const { createCoreRouter } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreRouter('api::category.category'); 10 | -------------------------------------------------------------------------------- /src/api/category/services/category.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * category service 5 | */ 6 | 7 | const { createCoreService } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreService('api::category.category'); 10 | -------------------------------------------------------------------------------- /src/api/order/content-types/order/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "collectionType", 3 | "collectionName": "orders", 4 | "info": { 5 | "singularName": "order", 6 | "pluralName": "orders", 7 | "displayName": "Order" 8 | }, 9 | "options": { 10 | "draftAndPublish": true 11 | }, 12 | "pluginOptions": {}, 13 | "attributes": { 14 | "stripeId": { 15 | "type": "string" 16 | }, 17 | "products": { 18 | "type": "json" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/api/order/controllers/order.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | /** 4 | * order controller 5 | */ 6 | 7 | const { createCoreController } = require("@strapi/strapi").factories; 8 | const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); 9 | 10 | 11 | module.exports = createCoreController("api::order.order", ({ strapi }) => ({ 12 | async customOrderController(ctx) { 13 | try { 14 | const bodyData = ctx.body; 15 | 16 | const entries = await strapi.entityService.findMany('api::product.product', { 17 | fields: ['title'], 18 | limit: 2 19 | }) 20 | 21 | return { data: entries }; 22 | } catch (err) { 23 | ctx.body = err; 24 | } 25 | }, 26 | 27 | async create(ctx) { 28 | try { 29 | const {products} = ctx.request.body; 30 | 31 | const lineItems = await Promise.all(products.map(async (product) => { 32 | 33 | const productEntities = await strapi.entityService.findMany("api::product.product", { 34 | filters: { 35 | key: product.key 36 | } 37 | }) 38 | const realProduct = productEntities[0]; 39 | const image = product.image 40 | return { 41 | price_data: { 42 | currency: 'inr', 43 | product_data: { 44 | name: realProduct.title, 45 | images: [image] 46 | }, 47 | unit_amount: realProduct.price * 100 48 | }, 49 | quantity: product.quantity 50 | } 51 | })); 52 | 53 | const session = await stripe.checkout.sessions.create({ 54 | shipping_address_collection: { 55 | allowed_countries: ['IN'] 56 | }, 57 | line_items: lineItems, 58 | mode: 'payment', 59 | success_url: `${process.env.CLIENT_BASE_URL}/payments/success`, 60 | cancel_url: `${process.env.CLIENT_BASE_URL}/payments/failed`, 61 | }); 62 | 63 | await strapi.entityService.create('api::order.order', { 64 | data: { 65 | products, 66 | stripeId: session.id 67 | }, 68 | }); 69 | 70 | return {stripeId: session.id}; 71 | 72 | } catch (error) { 73 | console.log(error); 74 | ctx.response.status = 500; 75 | return error; 76 | } 77 | } 78 | 79 | })); 80 | -------------------------------------------------------------------------------- /src/api/order/routes/custom-router.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | routes: [ 3 | { 4 | method: 'GET', 5 | path: '/orders/customOrder', 6 | handler: 'order.customOrderController', 7 | }, 8 | ], 9 | }; -------------------------------------------------------------------------------- /src/api/order/routes/order.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * order router 5 | */ 6 | 7 | const { createCoreRouter } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreRouter('api::order.order'); 10 | -------------------------------------------------------------------------------- /src/api/order/services/order.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * order service 5 | */ 6 | 7 | const { createCoreService } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreService('api::order.order'); 10 | -------------------------------------------------------------------------------- /src/api/product/content-types/product/schema.json: -------------------------------------------------------------------------------- 1 | { 2 | "kind": "collectionType", 3 | "collectionName": "products", 4 | "info": { 5 | "singularName": "product", 6 | "pluralName": "products", 7 | "displayName": "Product", 8 | "description": "" 9 | }, 10 | "options": { 11 | "draftAndPublish": true 12 | }, 13 | "pluginOptions": {}, 14 | "attributes": { 15 | "title": { 16 | "type": "string", 17 | "required": true 18 | }, 19 | "desc": { 20 | "type": "text", 21 | "required": true 22 | }, 23 | "price": { 24 | "type": "integer", 25 | "required": true 26 | }, 27 | "category": { 28 | "type": "relation", 29 | "relation": "manyToOne", 30 | "target": "api::category.category", 31 | "inversedBy": "products" 32 | }, 33 | "image": { 34 | "type": "media", 35 | "multiple": false, 36 | "required": true, 37 | "allowedTypes": [ 38 | "images" 39 | ] 40 | }, 41 | "key": { 42 | "type": "uid", 43 | "targetField": "title", 44 | "required": true 45 | }, 46 | "isTopPick": { 47 | "type": "boolean", 48 | "default": false 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/api/product/controllers/product.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * product controller 5 | */ 6 | 7 | const { createCoreController } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreController('api::product.product'); 10 | -------------------------------------------------------------------------------- /src/api/product/routes/product.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * product router 5 | */ 6 | 7 | const { createCoreRouter } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreRouter('api::product.product'); 10 | -------------------------------------------------------------------------------- /src/api/product/services/product.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * product service 5 | */ 6 | 7 | const { createCoreService } = require('@strapi/strapi').factories; 8 | 9 | module.exports = createCoreService('api::product.product'); 10 | -------------------------------------------------------------------------------- /src/extensions/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codingshuttle/fswd-22-ecommerce-strapi-server/8aa7d3b92f32b18428faaf5c0cc27105ab656551/src/extensions/.gitkeep -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | /** 5 | * An asynchronous register function that runs before 6 | * your application is initialized. 7 | * 8 | * This gives you an opportunity to extend code. 9 | */ 10 | register(/*{ strapi }*/) {}, 11 | 12 | /** 13 | * An asynchronous bootstrap function that runs before 14 | * your application gets started. 15 | * 16 | * This gives you an opportunity to set up your data model, 17 | * run jobs, or perform some special logic. 18 | */ 19 | bootstrap(/*{ strapi }*/) {}, 20 | }; 21 | --------------------------------------------------------------------------------