Skip to content

Commit

Permalink
🌺 Initial files
Browse files Browse the repository at this point in the history
  • Loading branch information
Muhammad Owais committed Nov 4, 2021
0 parents commit 684c0b3
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
extends: ['airbnb-base', 'plugin:prettier/recommended'],
parserOptions: {
ecmaVersion: 2020,
},
rules: {
'sort-keys': 0,
'sort-vars': 1,
'no-underscore-dangle': 0,
'no-console': 1,
'no-return-assign': 0,
'consistent-return': 0,
'func-names': 0,
'no-use-before-define': 0,
'no-plusplus': 0,
},
};
95 changes: 95 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Custom configs
# config
.keep
yarn.lock
package-lock.json

# Output files
dist

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.dev

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Firebase
.firebaserc
firebase.json
*.cache
4 changes: 4 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}
20 changes: 20 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
The MIT License (MIT)

DummyJSON - Muhammad Ovi

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
58 changes: 58 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# DummyJSON

[DummyJSON](https://dummyjson.com) is a free online REST API that you can use whenever you need some placeholder data for your front-end website or single-page application without running any server-side code.
It's awesome for teaching purposes, sample codes, testing, prototyping.

Checkout the detailed docs at [DummyJSON/Docs](https://dummyjson.com/docs/) for samples.

## Why?

Most of the time when we create a front-end application or website for learning or for client, we have to rely on the backend to implement the front-end or if we want to create a simple learning application we have to use hard-coded data, recently I found myself in need of some data.

I didn't like the idea of using some public API because I had the feeling that I was spending more time registering a client and understanding a complex API than focusing on my task.

So I decided to code a simple backend server that solved my problem, and here's DummyJSON.

You can find it running here and are free to use it in your developments and prototypes: https://dummyjson.com.

I hope you will find it useful.

## Features

- No Sign-up/Registration
- Zero-configuration
- Basic and Advanced API
- Resources relationships
- Filters and nested resources
- Supports GET, POST, PUT, PATCH, and DELETE http methods
- HTTP and HTTPS both works just fine
- Compatible with React, Angular, Vue, Ember, and vanilla JavaScript

## Resources

There are 8 resources available for you:

- products https://dummyjson.com/products/
- carts https://dummyjson.com/carts/
- users https://dummyjson.com/users/
- posts https://dummyjson.com/posts/
- comments https://dummyjson.com/comments/
- quotes https://dummyjson.com/quotes/
- todos https://dummyjson.com/todos/
- auth https://dummyjson.com/auth/

## How to

you can fetch data with any kind of methods you know(fetch API, Axios, jquery ajax,...)

### Get all products

```js
fetch('https://dummyjson.com/products')
.then(res => res.json())
.then(json => console.log(json));
```

Note: Pagination is also supported

See all the routes: https://dummyjson.com/docs/
19 changes: 19 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// require node version>=14.0 to run the app,
// because we use optional chaining etc...
const express = require('express');

const { version } = require('./package.json');

const { PORT = 3000 } = process.env;

const app = express();

// routes
app.use('/', (req, res) => {
res.send('Hello world!')
});

// start listening
app.listen(PORT, () => {
console.info(`[Service:Node] App v${version} running on port ${PORT}`);
});
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "dummy-json",
"version": "0.0.1",
"main": "index.js",
"author": "Muhammad Ovi <[email protected]>",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"engines": {
"node": ">=14.0"
},
"license": "MIT",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"eslint": "7.5",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.1",
"nodemon": "^1.19.3",
"prettier": "^1.18.2"
}
}

0 comments on commit 684c0b3

Please sign in to comment.