Repository: Shopify/shopify-node-app
Branch: master
Commit: feb4e29988c0
Files: 20
Total size: 21.1 KB
Directory structure:
gitextract_sosbrxnk/
├── .babelrc
├── .eslintrc
├── .gitignore
├── .nvmrc
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── bin/
│ └── www.js
├── client/
│ ├── App.js
│ ├── actions/
│ │ └── index.js
│ ├── components/
│ │ ├── ApiConsole.js
│ │ └── VerbPicker.js
│ ├── index.js
│ └── store/
│ └── index.js
├── config/
│ └── webpack.config.js
├── package.json
└── server/
├── index.js
└── views/
├── app.ejs
├── error.ejs
└── install.ejs
================================================
FILE CONTENTS
================================================
================================================
FILE: .babelrc
================================================
{
"presets": [
"react",
"env",
"es2015"
],
"plugins": [
"react-hot-loader/babel",
"transform-object-rest-spread",
"transform-class-properties"
]
}
================================================
FILE: .eslintrc
================================================
{
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": "error"
},
"extends": [
"prettier"
]
}
================================================
FILE: .gitignore
================================================
.env
.DS_Store
assets/
node_modules/
dump.rdb
main.js
db.sqlite3
================================================
FILE: .nvmrc
================================================
8.1.0
================================================
FILE: CONTRIBUTING.md
================================================
# How to contribute
This project is deprecated. Contributions will not be accepted.
================================================
FILE: LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2017 Shopify Inc.
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.
================================================
FILE: README.md
================================================
# This project is deprecated
This project is deprecated and not supported by Shopify.
This project contains **out-of-date dependencies** with **known security vulnerabilities** and **should not be used in a production environment**.
If you are looking for information about building a Shopify app with Node.js, please see our [Build a Shopify App with Node.js and React](https://developers.shopify.com/tutorials/build-a-shopify-app-with-node-and-react) tutorial.
================================================
FILE: bin/www.js
================================================
#!/usr/bin/env node
require('dotenv').config();
const chalk = require('chalk');
const http = require('http');
const app = require('../server');
const port = process.env.SHOPIFY_APP_PORT || '3000';
app.set('port', port);
const server = http.createServer(app);
server.listen(port, err => {
if (err) {
return console.log('😫', chalk.red(err));
}
console.log(`🚀 Now listening on port ${chalk.green(port)}`);
});
================================================
FILE: client/App.js
================================================
import React, { Component } from 'react';
import { Page, AppProvider } from '@shopify/polaris';
import ApiConsole from './components/ApiConsole'
class App extends Component {
render() {
const { apiKey, shopOrigin } = window;
return (
);
}
}
export default App;
================================================
FILE: client/actions/index.js
================================================
export function updateVerb(verb) {
return {
type: 'UPDATE_VERB',
payload: {
verb,
},
};
}
export function updatePath(path) {
return {
type: 'UPDATE_PATH',
payload: {
path,
},
};
}
export function updateParams(params) {
return {
type: 'UPDATE_PARAMS',
payload: {
params,
},
};
}
export function sendRequest(requestFields) {
const { verb, path, params } = requestFields;
const fetchOptions = {
method: verb,
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
credentials: 'include',
}
if (verb !== 'GET') {
fetchOptions['body'] = params
}
return dispatch => {
dispatch(requestStartAction());
return fetch(`/shopify/api${path}`, fetchOptions)
.then(response => response.json())
.then(json => dispatch(requestCompleteAction(json)))
.catch(error => {
dispatch(requestErrorAction(error));
});
};
}
function requestStartAction() {
return {
type: 'REQUEST_START',
payload: {},
};
}
function requestCompleteAction(json) {
const responseBody = JSON.stringify(json, null, 2);
return {
type: 'REQUEST_COMPLETE',
payload: {
responseBody
},
};
}
function requestErrorAction(requestError) {
return {
type: 'REQUEST_ERROR',
payload: {
requestError,
},
};
}
================================================
FILE: client/components/ApiConsole.js
================================================
import React, { Component} from 'react';
import { connect } from 'react-redux';
import { Layout, Stack, Card, TextField, Button } from '@shopify/polaris';
import ObjectInspector from 'react-object-inspector';
import { updatePath, updateParams, sendRequest } from '../actions';
import VerbPicker from './VerbPicker';
class ApiConsole extends Component {
render() {
return (
{ this.renderForm() }
{ this.renderResponse() }
)
}
renderForm() {
const { dispatch, requestFields } = this.props;
return (