- this.handleMenuItemClick(event, index)
- }
+ this.handleMenuItemClick(event, index)}
>
{option}
diff --git a/src/front/index.css b/src/front/index.css
index d701104..3104449 100644
--- a/src/front/index.css
+++ b/src/front/index.css
@@ -10,4 +10,4 @@ a {
.spacer {
flex: 1;
-}
\ No newline at end of file
+}
diff --git a/src/front/pages/details/details.jsx b/src/front/pages/details/details.jsx
index 801791c..f0431da 100644
--- a/src/front/pages/details/details.jsx
+++ b/src/front/pages/details/details.jsx
@@ -77,8 +77,8 @@ class DetailsPage extends React.PureComponent {
componentDidMount() {
const { match } = this.props;
- getApplication(match.params.appId).then(res => {
- this.setState(prevState => {
+ getApplication(match.params.appId).then((res) => {
+ this.setState((prevState) => {
return {
...prevState,
loading: false,
@@ -140,7 +140,7 @@ class DetailsPage extends React.PureComponent {
copyToClipboard(key) {
const { application } = this.state;
- navigator.permissions.query({ name: 'clipboard-write' }).then(result => {
+ navigator.permissions.query({ name: 'clipboard-write' }).then((result) => {
if (result.state === 'granted' || result.state === 'prompt') {
navigator.clipboard.writeText(application[key]);
this.setState({ snackBarOpen: true });
@@ -170,7 +170,7 @@ class DetailsPage extends React.PureComponent {
className={classes.textField}
fullWidth
value={application.name}
- onChange={event => this.handleChange('name', event)}
+ onChange={(event) => this.handleChange('name', event)}
margin="normal"
variant="outlined"
error={errors.name}
@@ -182,7 +182,7 @@ class DetailsPage extends React.PureComponent {
className={classes.textField}
fullWidth
value={application.description}
- onChange={event => this.handleChange('description', event)}
+ onChange={(event) => this.handleChange('description', event)}
margin="normal"
variant="outlined"
multiline
@@ -196,7 +196,8 @@ class DetailsPage extends React.PureComponent {
className={classes.textField}
fullWidth
value={application.apple_store_link || ''}
- onChange={event => this.handleChange('apple_store_link', event)}
+ onChange={(event) =>
+ this.handleChange('apple_store_link', event)}
margin="normal"
variant="outlined"
error={errors.apple_store_link}
@@ -208,9 +209,8 @@ class DetailsPage extends React.PureComponent {
className={classes.textField}
fullWidth
value={application.google_market_link || ''}
- onChange={event =>
- this.handleChange('google_market_link', event)
- }
+ onChange={(event) =>
+ this.handleChange('google_market_link', event)}
margin="normal"
variant="outlined"
error={errors.google_market_link}
diff --git a/src/front/pages/home/home.jsx b/src/front/pages/home/home.jsx
index c84026a..cc16309 100644
--- a/src/front/pages/home/home.jsx
+++ b/src/front/pages/home/home.jsx
@@ -87,7 +87,7 @@ class HomePage extends React.PureComponent {
}
componentDidMount() {
- listOfApplications().then(res => {
+ listOfApplications().then((res) => {
this.setState({
loading: false,
developerApplications: res,
@@ -165,7 +165,7 @@ class HomePage extends React.PureComponent {
{loading && }
{!loading &&
- developerApplications.map(application => (
+ developerApplications.map((application) => (
+ <>
{application.name}
-
+ >
}
secondary={application.description}
/>
@@ -245,7 +245,7 @@ class HomePage extends React.PureComponent {
className={classes.textField}
fullWidth
value={newApplication.name}
- onChange={event => this.handleChange('name', event)}
+ onChange={(event) => this.handleChange('name', event)}
margin="normal"
variant="outlined"
error={errors.name}
@@ -258,7 +258,7 @@ class HomePage extends React.PureComponent {
className={classes.textField}
fullWidth
value={newApplication.description}
- onChange={event => this.handleChange('description', event)}
+ onChange={(event) => this.handleChange('description', event)}
margin="normal"
variant="outlined"
multiline
@@ -272,7 +272,7 @@ class HomePage extends React.PureComponent {
className={classes.textField}
fullWidth
value={newApplication.apple_store_link}
- onChange={event => this.handleChange('apple_store_link', event)}
+ onChange={(event) => this.handleChange('apple_store_link', event)}
margin="normal"
variant="outlined"
error={errors.apple_store_link}
@@ -284,7 +284,8 @@ class HomePage extends React.PureComponent {
className={classes.textField}
fullWidth
value={newApplication.google_market_link}
- onChange={event => this.handleChange('google_market_link', event)}
+ onChange={(event) =>
+ this.handleChange('google_market_link', event)}
margin="normal"
variant="outlined"
error={errors.google_market_link}
diff --git a/src/front/pages/profile/profile.jsx b/src/front/pages/profile/profile.jsx
index a3e6247..3a07ce0 100644
--- a/src/front/pages/profile/profile.jsx
+++ b/src/front/pages/profile/profile.jsx
@@ -123,7 +123,7 @@ class ProfilePage extends React.PureComponent {
className={classes.textField}
fullWidth
value={user.name}
- onChange={event => this.handleChange('name', event)}
+ onChange={(event) => this.handleChange('name', event)}
margin="normal"
variant="outlined"
/>
@@ -135,7 +135,7 @@ class ProfilePage extends React.PureComponent {
className={classes.textField}
fullWidth
value={user.login}
- onChange={event => this.handleChange('githubLogin', event)}
+ onChange={(event) => this.handleChange('githubLogin', event)}
margin="normal"
variant="outlined"
/>
diff --git a/src/front/registerServiceWorker.jsx b/src/front/registerServiceWorker.jsx
index a8cc8a1..5294c90 100644
--- a/src/front/registerServiceWorker.jsx
+++ b/src/front/registerServiceWorker.jsx
@@ -59,7 +59,7 @@ export default function register() {
function registerValidSW(swUrl) {
navigator.serviceWorker
.register(swUrl)
- .then(registration => {
+ .then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker) {
@@ -82,7 +82,7 @@ function registerValidSW(swUrl) {
}
};
})
- .catch(error => {
+ .catch((error) => {
console.error('Error during service worker registration:', error);
});
}
@@ -90,14 +90,14 @@ function registerValidSW(swUrl) {
function checkValidServiceWorker(swUrl) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl)
- .then(response => {
+ .then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
if (
response.status === 404 ||
response.headers.get('content-type').indexOf('javascript') === -1
) {
// No service worker found. Probably a different app. Reload the page.
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
@@ -116,7 +116,7 @@ function checkValidServiceWorker(swUrl) {
export function unregister() {
if ('serviceWorker' in navigator) {
- navigator.serviceWorker.ready.then(registration => {
+ navigator.serviceWorker.ready.then((registration) => {
registration.unregister();
});
}
diff --git a/src/front/services/api.jsx b/src/front/services/api.jsx
index d84a531..3159ffb 100644
--- a/src/front/services/api.jsx
+++ b/src/front/services/api.jsx
@@ -34,7 +34,7 @@ export const listOfApplications = async () => {
/*
Returns details of one application
*/
-export const getApplication = async appId => {
+export const getApplication = async (appId) => {
const headers = headersWithJWT();
if (!headers) {
return {};
@@ -53,7 +53,7 @@ export const getApplication = async appId => {
/*
Create a new application on the connected user
*/
-export const createApplication = async newApplication => {
+export const createApplication = async (newApplication) => {
const headers = headersWithJWT();
if (!headers) {
return {};
diff --git a/src/front/services/auth.jsx b/src/front/services/auth.jsx
index c555707..c3126d1 100644
--- a/src/front/services/auth.jsx
+++ b/src/front/services/auth.jsx
@@ -9,7 +9,7 @@ export const logout = () => {
Cookie.remove(COOKIENAME);
};
-const isJwtValid = jwt => {
+const isJwtValid = (jwt) => {
if (!jwt) {
return false;
}
@@ -32,7 +32,7 @@ const isJwtValid = jwt => {
return now < exp;
};
-export const setAuthToken = token => {
+export const setAuthToken = (token) => {
if (!isJwtValid(token)) {
connectedState.next(false);
return false;
diff --git a/src/front/services/formValidator.jsx b/src/front/services/formValidator.jsx
index a5eb968..75439a2 100644
--- a/src/front/services/formValidator.jsx
+++ b/src/front/services/formValidator.jsx
@@ -30,9 +30,9 @@ export const validateFormField = (value, field) => {
return validated;
};
-export const checkValid = errorState => {
+export const checkValid = (errorState) => {
let valid = true;
- Object.keys(errorState).forEach(element => {
+ Object.keys(errorState).forEach((element) => {
if (errorState[element] === true) {
valid = false;
}
diff --git a/src/logger.js b/src/logger.js
index 620d35a..713f0c0 100644
--- a/src/logger.js
+++ b/src/logger.js
@@ -60,7 +60,7 @@ function createFormatMessage(name) {
* @param {*} severity
*/
function addSeverity(severity) {
- return params => ({
+ return (params) => ({
...params,
severity,
});
diff --git a/src/middleware/parse.js b/src/middleware/parse.js
index fb0083d..7e34715 100644
--- a/src/middleware/parse.js
+++ b/src/middleware/parse.js
@@ -8,8 +8,8 @@ const {
PARSE_MASTER_KEY,
PARSE_READONLY_MASTER_KEY,
PARSE_SILENT,
-} = require('./../config');
-const cloud = require('./../parse/cloud/main');
+} = require('../config');
+const cloud = require('../parse/cloud/main');
class ParseMiddelware {
constructor(app) {
@@ -17,10 +17,10 @@ class ParseMiddelware {
}
static start(options, parseCloudEvent) {
- return new Promise(resolve => {
+ return new Promise((resolve) => {
let parseMiddelware;
const parseOptions = Object.assign(options, {
- cloud: Parse => {
+ cloud: (Parse) => {
cloud(Parse, parseCloudEvent);
},
serverStartComplete: () => {
@@ -34,7 +34,7 @@ class ParseMiddelware {
}
}
-module.exports = parseCloudEvent =>
+module.exports = (parseCloudEvent) =>
ParseMiddelware.start(
{
databaseURI: MONGO_URI,
diff --git a/src/middleware/parseDashboard.js b/src/middleware/parseDashboard.js
index 73b7cb2..4f573d3 100644
--- a/src/middleware/parseDashboard.js
+++ b/src/middleware/parseDashboard.js
@@ -12,7 +12,7 @@ const {
PARSE_READONLY_MASTER_KEY,
PARSE_DASHBOARD_MAINTENER_PWD,
PARSE_DASHBOARD_ROOT_PWD,
-} = require('./../config');
+} = require('../config');
module.exports = () =>
new ParseDashboard({
diff --git a/src/middleware/parseSandbox.js b/src/middleware/parseSandbox.js
index 1cab8e3..edb5a8d 100644
--- a/src/middleware/parseSandbox.js
+++ b/src/middleware/parseSandbox.js
@@ -7,7 +7,7 @@ const {
PARSE_FILE_KEY,
PARSE_MASTER_KEY,
PARSE_READONLY_MASTER_KEY,
-} = require('./../config');
+} = require('../config');
module.exports = () =>
new ParseServer({
diff --git a/src/middleware/parseSwagger.js b/src/middleware/parseSwagger.js
index 47dc897..604758a 100644
--- a/src/middleware/parseSwagger.js
+++ b/src/middleware/parseSwagger.js
@@ -1,5 +1,5 @@
const ParseSwagger = require('../parse/parse-server-swagger');
-const { PARSE_APP_ID, PARSE_MASTER_KEY, API_URL } = require('./../config');
+const { PARSE_APP_ID, PARSE_MASTER_KEY, API_URL } = require('../config');
module.exports = () =>
new ParseSwagger({
diff --git a/src/parse/cloud/main.js b/src/parse/cloud/main.js
index 5d5a40f..13a2846 100644
--- a/src/parse/cloud/main.js
+++ b/src/parse/cloud/main.js
@@ -1,5 +1,5 @@
/* eslint-disable no-undef */
-const logger = require('./../../logger');
+const logger = require('../../logger');
const schemaSync = require('../schema/sync');
const roleInstall = require('../role/install');
const roleGet = require('../role/get');
@@ -20,7 +20,7 @@ async function init(Parse) {
}
module.exports = (Parse, event) => {
- Parse.Cloud.afterSave(Parse.User, async req => {
+ Parse.Cloud.afterSave(Parse.User, async (req) => {
if (req.object.existed()) {
return null;
}
@@ -49,5 +49,5 @@ module.exports = (Parse, event) => {
}
logger.info(`Parse correctly init`);
})
- .catch(err => logger.info(`Issue to init Parse : ${err}`));
+ .catch((err) => logger.info(`Issue to init Parse : ${err}`));
};
diff --git a/src/parse/cloud/setAfterFind.js b/src/parse/cloud/setAfterFind.js
index 5c6575c..3058d00 100644
--- a/src/parse/cloud/setAfterFind.js
+++ b/src/parse/cloud/setAfterFind.js
@@ -1,9 +1,9 @@
-const getClasses = require('./../schema/getClasses');
+const getClasses = require('../schema/getClasses');
-module.exports = async Parse => {
+module.exports = async (Parse) => {
const schemaClasses = await getClasses();
for (const schemaClass of schemaClasses) {
- Parse.Cloud.afterFind(schemaClass.className, req => {
+ Parse.Cloud.afterFind(schemaClass.className, (req) => {
if (req.master) {
return;
}
diff --git a/src/parse/cloud/setAfterSave.js b/src/parse/cloud/setAfterSave.js
index d1f2b08..3449c24 100644
--- a/src/parse/cloud/setAfterSave.js
+++ b/src/parse/cloud/setAfterSave.js
@@ -1,9 +1,9 @@
-const getClasses = require('./../schema/getClasses');
+const getClasses = require('../schema/getClasses');
-module.exports = async Parse => {
+module.exports = async (Parse) => {
const schemaClasses = await getClasses();
for (const schemaClass of schemaClasses) {
- Parse.Cloud.afterSave(schemaClass.className, req => {
+ Parse.Cloud.afterSave(schemaClass.className, (req) => {
const jsonObject = req.object.toJSON();
delete jsonObject.owner;
delete jsonObject.ACL;
diff --git a/src/parse/cloud/setBeforeSave.js b/src/parse/cloud/setBeforeSave.js
index a23e24c..072c27b 100644
--- a/src/parse/cloud/setBeforeSave.js
+++ b/src/parse/cloud/setBeforeSave.js
@@ -1,9 +1,9 @@
-const getClasses = require('./../schema/getClasses');
+const getClasses = require('../schema/getClasses');
-module.exports = async Parse => {
+module.exports = async (Parse) => {
const schemaClasses = await getClasses();
for (const schemaClass of schemaClasses) {
- Parse.Cloud.beforeSave(schemaClass.className, req => {
+ Parse.Cloud.beforeSave(schemaClass.className, (req) => {
if (!req.user) {
return;
}
diff --git a/src/parse/index.js b/src/parse/index.js
index 315bed0..0489e9c 100644
--- a/src/parse/index.js
+++ b/src/parse/index.js
@@ -4,7 +4,7 @@ const {
PARSE_MASTER_KEY,
API_URL,
SANDBOX_URL,
-} = require('./../config');
+} = require('../config');
class Parse {
static async signUp(username, password, isSandbox) {
diff --git a/src/parse/parse-server-swagger/index.js b/src/parse/parse-server-swagger/index.js
index 7f7b60e..2da1643 100644
--- a/src/parse/parse-server-swagger/index.js
+++ b/src/parse/parse-server-swagger/index.js
@@ -1,56 +1,56 @@
-// All credit to https://github.com/bhtz/parse-server-swagger
-// the code is adapted for our use case
-
-const express = require('express');
-const swaggerUi = require('swagger-ui-express');
-const request = require('request-promise');
-const { parseSchemaToSwagger } = require('./schema-to-swagger');
-const parseBaseSwaggerSpec = require('./parse-swagger-base.json');
-
-/**
- * constructor
- * @returns app: express middleware
- */
-function ParseSwagger(options) {
- this.config = options;
-
- const app = express();
-
- const swagOpts = { swaggerUrl: `${this.config.host}/api-docs` };
- app.use('/swagger', swaggerUi.serve, swaggerUi.setup(null, swagOpts));
- app.use('/api-docs', this.renderSwaggerSpec.bind(this));
-
- return app;
-}
-
-/**
- * Get parse compatible api swagger.json base
- */
-ParseSwagger.prototype.renderSwaggerSpec = (_, res) => {
- const options = {
- url: `${this.config.host} ${this.config.apiRoot}/schemas`,
- method: 'GET',
- json: true,
- headers: {
- 'X-Parse-Application-Id': this.config.appId,
- 'X-Parse-Master-Key': this.config.masterKey,
- },
- };
-
- const excludes = this.config.excludes || [];
-
- request(options)
- .then(data => {
- const swagger = parseSchemaToSwagger(
- parseBaseSwaggerSpec,
- data.results,
- excludes,
- );
- res.json(swagger);
- })
- .catch(error => {
- res.send(`Request failed with response code ${error.statu}`);
- });
-};
-
-module.exports = ParseSwagger;
+// All credit to https://github.com/bhtz/parse-server-swagger
+// the code is adapted for our use case
+
+const express = require('express');
+const swaggerUi = require('swagger-ui-express');
+const request = require('request-promise');
+const { parseSchemaToSwagger } = require('./schema-to-swagger');
+const parseBaseSwaggerSpec = require('./parse-swagger-base.json');
+
+/**
+ * constructor
+ * @returns app: express middleware
+ */
+function ParseSwagger(options) {
+ this.config = options;
+
+ const app = express();
+
+ const swagOpts = { swaggerUrl: `${this.config.host}/api-docs` };
+ app.use('/swagger', swaggerUi.serve, swaggerUi.setup(null, swagOpts));
+ app.use('/api-docs', this.renderSwaggerSpec.bind(this));
+
+ return app;
+}
+
+/**
+ * Get parse compatible api swagger.json base
+ */
+ParseSwagger.prototype.renderSwaggerSpec = (_, res) => {
+ const options = {
+ url: `${this.config.host} ${this.config.apiRoot}/schemas`,
+ method: 'GET',
+ json: true,
+ headers: {
+ 'X-Parse-Application-Id': this.config.appId,
+ 'X-Parse-Master-Key': this.config.masterKey,
+ },
+ };
+
+ const excludes = this.config.excludes || [];
+
+ request(options)
+ .then((data) => {
+ const swagger = parseSchemaToSwagger(
+ parseBaseSwaggerSpec,
+ data.results,
+ excludes,
+ );
+ res.json(swagger);
+ })
+ .catch((error) => {
+ res.send(`Request failed with response code ${error.statu}`);
+ });
+};
+
+module.exports = ParseSwagger;
diff --git a/src/parse/parse-server-swagger/parse-swagger-base.json b/src/parse/parse-server-swagger/parse-swagger-base.json
index 88935e5..3466947 100644
--- a/src/parse/parse-server-swagger/parse-swagger-base.json
+++ b/src/parse/parse-server-swagger/parse-swagger-base.json
@@ -1,61 +1,61 @@
-{
- "swagger": "2.0",
- "info": {
- "title": "Connect API",
- "description": "Full API documentation of the connect api",
- "version": "1.0.0"
- },
- "schemes": ["http", "https"],
- "securityDefinitions": {
- "ParseAppId": {
- "type": "apiKey",
- "name": "X-Parse-Application-Id",
- "in": "header"
- },
- "ParseSessionId": {
- "type": "apiKey",
- "name": "X-Parse-Session-Token",
- "in": "header"
- }
- },
- "basePath": "/",
- "produces": ["application/json"],
- "components": {
- "schemas": {
- "Batch": {
- "type": "object",
- "properties": {
- "requests": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "method": {
- "type": "string"
- },
- "path": {
- "type": "string"
- },
- "body": {
- "type": "object"
- }
- }
- }
- }
- }
- },
- "notfound": {
- "type": "object",
- "properties": {
- "code": {
- "type": "string"
- },
- "error": {
- "type": "string"
- }
- }
- }
- }
- },
- "paths": {}
-}
+{
+ "swagger": "2.0",
+ "info": {
+ "title": "Connect API",
+ "description": "Full API documentation of the connect api",
+ "version": "1.0.0"
+ },
+ "schemes": ["http", "https"],
+ "securityDefinitions": {
+ "ParseAppId": {
+ "type": "apiKey",
+ "name": "X-Parse-Application-Id",
+ "in": "header"
+ },
+ "ParseSessionId": {
+ "type": "apiKey",
+ "name": "X-Parse-Session-Token",
+ "in": "header"
+ }
+ },
+ "basePath": "/",
+ "produces": ["application/json"],
+ "components": {
+ "schemas": {
+ "Batch": {
+ "type": "object",
+ "properties": {
+ "requests": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "method": {
+ "type": "string"
+ },
+ "path": {
+ "type": "string"
+ },
+ "body": {
+ "type": "object"
+ }
+ }
+ }
+ }
+ }
+ },
+ "notfound": {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "string"
+ },
+ "error": {
+ "type": "string"
+ }
+ }
+ }
+ }
+ },
+ "paths": {}
+}
diff --git a/src/parse/parse-server-swagger/schema-to-swagger.js b/src/parse/parse-server-swagger/schema-to-swagger.js
index 8c9c127..cf73ca8 100644
--- a/src/parse/parse-server-swagger/schema-to-swagger.js
+++ b/src/parse/parse-server-swagger/schema-to-swagger.js
@@ -1,272 +1,272 @@
-/**
- * Cast parse type to swagger type
- * @param {Parse type} type
- */
-function schemaTypeToSwaggerType(type) {
- let swaggerType;
- switch (type) {
- case 'String':
- swaggerType = { type: 'string' };
- break;
-
- case 'Number':
- swaggerType = { type: 'number' };
- break;
-
- case 'Boolean':
- swaggerType = { type: 'boolean' };
- break;
-
- case 'Array':
- swaggerType = { type: 'array', items: { type: 'object' } };
- break;
-
- case 'Object':
- swaggerType = { type: 'object' };
- break;
-
- case 'File':
- swaggerType = { type: 'object' };
- break;
-
- case 'Pointer':
- swaggerType = { type: 'object' };
- break;
-
- case 'Relation':
- swaggerType = { type: 'object' };
- break;
-
- default:
- swaggerType = { type: 'string' };
- break;
- }
- return swaggerType;
-}
-
-/**
- * Get swagger configuration (CREATE, READ) for parse endpoint
- * @param {*} classes
- */
-function getPath(classes) {
- return {
- get: {
- security: [{ ParseAppId: [], ParseSessionId: [] }],
- summary: `Get ${classes.className} data`,
- description:
- 'Find queries documentation here https://docs.parseplatform.org/rest/guide/#queries',
- tags: [`${classes.className}`],
- responses: {
- '200': {
- description: `Return ${classes.className} data`,
- schema: {
- $ref: `#/components/schemas/${classes.className}`,
- },
- },
- '400': { description: 'Bad Request' },
- '401': { description: 'Unauthorized' },
- '406': { description: 'Not Acceptable' },
- '500': { description: 'Server Internal error' },
- },
- },
- post: {
- security: [{ ParseAppId: [], ParseSessionId: [] }],
- summary: 'Add object instance',
- description: 'Happy to access The System',
- tags: [`${classes.className}`],
- parameters: [
- {
- in: 'body',
- name: 'body',
- description: 'object that needs to be added to the store',
- required: true,
- schema: {
- $ref: `#/components/schemas/${classes.className}`,
- },
- },
- ],
- responses: {
- '200': {
- description: `Returns ${classes.className} data`,
- schema: {
- $ref: `#/components/schemas/${classes.className}`,
- },
- },
- '400': { description: 'Bad Request' },
- '401': { description: 'Unauthorized' },
- '406': { description: 'Not Acceptable' },
- '500': { description: 'Server Internal error' },
- },
- },
- };
-}
-
-/**
- * Get swagger configuration (UPDATE, READ, DELETE) for parse endpoint
- * @param {*} classes
- */
-function getPathById(classes) {
- return {
- get: {
- security: [
- {
- ParseAppId: [],
- ParseSessionId: [],
- },
- ],
- summary: `Get ${classes.className} by id`,
- description: 'Happy to access The System',
- tags: [`${classes.className}`],
- parameters: [
- {
- in: 'path',
- name: 'id',
- type: 'string',
- description: 'The id of the element you want to get.',
- required: true,
- },
- ],
- responses: {
- '200': {
- description: 'Returns data',
- schema: {
- $ref: `#/components/schemas/${classes.className}`,
- },
- },
- '400': { description: 'Bad Request' },
- '401': { description: 'Unauthorized' },
- '406': { description: 'Not Acceptable' },
- '500': { description: 'Server Internal error' },
- },
- },
- put: {
- security: [
- {
- ParseAppId: [],
- ParseSessionId: [],
- },
- ],
- summary: 'Update instance',
- description: 'Happy to access The System',
- tags: [`${classes.className}`],
- parameters: [
- {
- in: 'path',
- name: 'id',
- type: 'string',
- description: 'The id of the element you want to update.',
- required: true,
- },
- {
- in: 'body',
- name: 'movie',
- description: 'The element you want update with.',
- required: true,
- schema: {
- $ref: `#/components/schemas/${classes.className}`,
- },
- },
- ],
- responses: {
- '200': {
- description: 'Returns instance data',
- schema: {
- $ref: `#/components/schemas/${classes.className}`,
- },
- },
- '400': {
- description: 'Bad Request',
- },
- '401': {
- description: 'Unauthorized',
- },
- '406': {
- description: 'Not Acceptable',
- },
- '500': {
- description: 'Server Internal error',
- },
- },
- },
- delete: {
- security: [
- {
- ParseAppId: [],
- ParseSessionId: [],
- },
- ],
- summary: 'Delete instance',
- description: 'Happy to access The System',
- tags: [`${classes.className}`],
- parameters: [
- {
- in: 'path',
- name: 'id',
- type: 'string',
- description: 'The id of the element you want to delete.',
- required: true,
- },
- ],
- responses: {
- '200': {
- description: 'Returns a confirmation message',
- },
- '400': {
- description: 'Bad Request',
- },
- '401': {
- description: 'Unauthorized',
- },
- '404': {
- description: 'Id not found',
- schema: {
- $ref: '#/components/schemas/notfound',
- },
- },
- '406': {
- description: 'Not Acceptable',
- },
- '500': {
- description: 'Server Internal error',
- },
- },
- },
- };
-}
-
-/**
- *
- * @param {classe} parse server classes
- */
-function transformClasseToSchema(classe) {
- const schema = { type: 'object', properties: {} };
-
- classe.forEach((element, key) => {
- if (key !== 'ACL') {
- schema.properties[key] = schemaTypeToSwaggerType(element.type);
- }
- });
-
- return schema;
-}
-
-/**
- * Transform Parse Server schema.json to swagger.json
- */
-exports.parseSchemaToSwagger = (spec, schemas, excludes) => {
- const newSpec = spec;
-
- for (const classes of schemas) {
- if (!excludes.includes(classes.className)) {
- newSpec.components.schemas[classes.className] = transformClasseToSchema(
- classes,
- );
- newSpec.paths[`/parse/classes/${classes.className}`] = getPath(classes);
- newSpec.paths[`/parse/classes/${classes.className}/{id}`] = getPathById(
- classes,
- );
- }
- }
-
- return spec;
-};
+/**
+ * Cast parse type to swagger type
+ * @param {Parse type} type
+ */
+function schemaTypeToSwaggerType(type) {
+ let swaggerType;
+ switch (type) {
+ case 'String':
+ swaggerType = { type: 'string' };
+ break;
+
+ case 'Number':
+ swaggerType = { type: 'number' };
+ break;
+
+ case 'Boolean':
+ swaggerType = { type: 'boolean' };
+ break;
+
+ case 'Array':
+ swaggerType = { type: 'array', items: { type: 'object' } };
+ break;
+
+ case 'Object':
+ swaggerType = { type: 'object' };
+ break;
+
+ case 'File':
+ swaggerType = { type: 'object' };
+ break;
+
+ case 'Pointer':
+ swaggerType = { type: 'object' };
+ break;
+
+ case 'Relation':
+ swaggerType = { type: 'object' };
+ break;
+
+ default:
+ swaggerType = { type: 'string' };
+ break;
+ }
+ return swaggerType;
+}
+
+/**
+ * Get swagger configuration (CREATE, READ) for parse endpoint
+ * @param {*} classes
+ */
+function getPath(classes) {
+ return {
+ get: {
+ security: [{ ParseAppId: [], ParseSessionId: [] }],
+ summary: `Get ${classes.className} data`,
+ description:
+ 'Find queries documentation here https://docs.parseplatform.org/rest/guide/#queries',
+ tags: [`${classes.className}`],
+ responses: {
+ 200: {
+ description: `Return ${classes.className} data`,
+ schema: {
+ $ref: `#/components/schemas/${classes.className}`,
+ },
+ },
+ 400: { description: 'Bad Request' },
+ 401: { description: 'Unauthorized' },
+ 406: { description: 'Not Acceptable' },
+ 500: { description: 'Server Internal error' },
+ },
+ },
+ post: {
+ security: [{ ParseAppId: [], ParseSessionId: [] }],
+ summary: 'Add object instance',
+ description: 'Happy to access The System',
+ tags: [`${classes.className}`],
+ parameters: [
+ {
+ in: 'body',
+ name: 'body',
+ description: 'object that needs to be added to the store',
+ required: true,
+ schema: {
+ $ref: `#/components/schemas/${classes.className}`,
+ },
+ },
+ ],
+ responses: {
+ 200: {
+ description: `Returns ${classes.className} data`,
+ schema: {
+ $ref: `#/components/schemas/${classes.className}`,
+ },
+ },
+ 400: { description: 'Bad Request' },
+ 401: { description: 'Unauthorized' },
+ 406: { description: 'Not Acceptable' },
+ 500: { description: 'Server Internal error' },
+ },
+ },
+ };
+}
+
+/**
+ * Get swagger configuration (UPDATE, READ, DELETE) for parse endpoint
+ * @param {*} classes
+ */
+function getPathById(classes) {
+ return {
+ get: {
+ security: [
+ {
+ ParseAppId: [],
+ ParseSessionId: [],
+ },
+ ],
+ summary: `Get ${classes.className} by id`,
+ description: 'Happy to access The System',
+ tags: [`${classes.className}`],
+ parameters: [
+ {
+ in: 'path',
+ name: 'id',
+ type: 'string',
+ description: 'The id of the element you want to get.',
+ required: true,
+ },
+ ],
+ responses: {
+ 200: {
+ description: 'Returns data',
+ schema: {
+ $ref: `#/components/schemas/${classes.className}`,
+ },
+ },
+ 400: { description: 'Bad Request' },
+ 401: { description: 'Unauthorized' },
+ 406: { description: 'Not Acceptable' },
+ 500: { description: 'Server Internal error' },
+ },
+ },
+ put: {
+ security: [
+ {
+ ParseAppId: [],
+ ParseSessionId: [],
+ },
+ ],
+ summary: 'Update instance',
+ description: 'Happy to access The System',
+ tags: [`${classes.className}`],
+ parameters: [
+ {
+ in: 'path',
+ name: 'id',
+ type: 'string',
+ description: 'The id of the element you want to update.',
+ required: true,
+ },
+ {
+ in: 'body',
+ name: 'movie',
+ description: 'The element you want update with.',
+ required: true,
+ schema: {
+ $ref: `#/components/schemas/${classes.className}`,
+ },
+ },
+ ],
+ responses: {
+ 200: {
+ description: 'Returns instance data',
+ schema: {
+ $ref: `#/components/schemas/${classes.className}`,
+ },
+ },
+ 400: {
+ description: 'Bad Request',
+ },
+ 401: {
+ description: 'Unauthorized',
+ },
+ 406: {
+ description: 'Not Acceptable',
+ },
+ 500: {
+ description: 'Server Internal error',
+ },
+ },
+ },
+ delete: {
+ security: [
+ {
+ ParseAppId: [],
+ ParseSessionId: [],
+ },
+ ],
+ summary: 'Delete instance',
+ description: 'Happy to access The System',
+ tags: [`${classes.className}`],
+ parameters: [
+ {
+ in: 'path',
+ name: 'id',
+ type: 'string',
+ description: 'The id of the element you want to delete.',
+ required: true,
+ },
+ ],
+ responses: {
+ 200: {
+ description: 'Returns a confirmation message',
+ },
+ 400: {
+ description: 'Bad Request',
+ },
+ 401: {
+ description: 'Unauthorized',
+ },
+ 404: {
+ description: 'Id not found',
+ schema: {
+ $ref: '#/components/schemas/notfound',
+ },
+ },
+ 406: {
+ description: 'Not Acceptable',
+ },
+ 500: {
+ description: 'Server Internal error',
+ },
+ },
+ },
+ };
+}
+
+/**
+ *
+ * @param {classe} parse server classes
+ */
+function transformClasseToSchema(classe) {
+ const schema = { type: 'object', properties: {} };
+
+ classe.forEach((element, key) => {
+ if (key !== 'ACL') {
+ schema.properties[key] = schemaTypeToSwaggerType(element.type);
+ }
+ });
+
+ return schema;
+}
+
+/**
+ * Transform Parse Server schema.json to swagger.json
+ */
+exports.parseSchemaToSwagger = (spec, schemas, excludes) => {
+ const newSpec = spec;
+
+ for (const classes of schemas) {
+ if (!excludes.includes(classes.className)) {
+ newSpec.components.schemas[classes.className] = transformClasseToSchema(
+ classes,
+ );
+ newSpec.paths[`/parse/classes/${classes.className}`] = getPath(classes);
+ newSpec.paths[`/parse/classes/${classes.className}/{id}`] = getPathById(
+ classes,
+ );
+ }
+ }
+
+ return spec;
+};
diff --git a/src/parse/schema/classes/jsonSchemaData.js b/src/parse/schema/classes/jsonSchemaData.js
index a9c2d1d..eeb3c42 100644
--- a/src/parse/schema/classes/jsonSchemaData.js
+++ b/src/parse/schema/classes/jsonSchemaData.js
@@ -1,7 +1,7 @@
module.exports = {
- className: "jsonSchemaData",
+ className: 'jsonSchemaData',
fields: {
- schemaURL: {type: "String"},
- data: {type: "Object"}
- }
+ schemaURL: { type: 'String' },
+ data: { type: 'Object' },
+ },
};
diff --git a/src/parse/schema/sanitizeClass.js b/src/parse/schema/sanitizeClass.js
index ec473b7..5a15a88 100644
--- a/src/parse/schema/sanitizeClass.js
+++ b/src/parse/schema/sanitizeClass.js
@@ -1,4 +1,4 @@
-module.exports = schemaClass => {
+module.exports = (schemaClass) => {
const newSchemaClass = schemaClass;
// even if it's set on the schema classes we remove it to be sure the great type an properties is setup
diff --git a/src/parse/schema/sync.js b/src/parse/schema/sync.js
index 8db006a..a564460 100644
--- a/src/parse/schema/sync.js
+++ b/src/parse/schema/sync.js
@@ -1,5 +1,5 @@
const Config = require('parse-server/lib/Config');
-const logger = require('./../../logger');
+const logger = require('../../logger');
const getClasses = require('./getClasses');
const sanitizeClass = require('./sanitizeClass');
const initClasses = require('./_initClasses');
@@ -36,7 +36,7 @@ async function applySchemaSync(schema, schemaClass) {
}
}
-module.exports = async appId => {
+module.exports = async (appId) => {
const schemaClasses = await getClasses();
const schema = await Config.get(appId).database.loadSchema();
diff --git a/webpack.conf.js b/webpack.config.js
similarity index 86%
rename from webpack.conf.js
rename to webpack.config.js
index a1ba311..94e753b 100644
--- a/webpack.conf.js
+++ b/webpack.config.js
@@ -14,7 +14,7 @@ const indexTemplate = getPath('src/front/public/index.html');
const EXTRACT_CSS = process.env.NODE_ENV === 'production';
const APPLY_OPTIMIZATIONS = process.env.NODE_ENV === 'production';
-const scssLoaders = cssOptions => [
+const scssLoaders = (cssOptions) => [
EXTRACT_CSS ? MiniCssExtractPlugin.loader : 'style-loader',
{
loader: 'css-loader',
@@ -27,11 +27,13 @@ module.exports = () => {
const env = dotenv.config().parsed;
// reduce it to a nice object, the same as before
- const envKeys = env ? Object.keys(env).reduce((prev, next) => {
- // eslint-disable-next-line no-param-reassign
- prev[`process.env.${next}`] = JSON.stringify(env[next]);
- return prev;
- }, {}) : {};
+ const envKeys = env
+ ? Object.keys(env).reduce((prev, next) => {
+ // eslint-disable-next-line no-param-reassign
+ prev[`process.env.${next}`] = JSON.stringify(env[next]);
+ return prev;
+ }, {})
+ : {};
return {
mode: process.env.NODE_ENV || 'development',
@@ -45,7 +47,7 @@ module.exports = () => {
devServer: {
inline: true,
port: process.env.FRONT_PORT,
- historyApiFallback: true
+ historyApiFallback: true,
},
module: {
rules: [
@@ -106,11 +108,11 @@ module.exports = () => {
},
optimization: APPLY_OPTIMIZATIONS
? {
- runtimeChunk: 'single',
- splitChunks: {
- chunks: 'all',
- },
- }
+ runtimeChunk: 'single',
+ splitChunks: {
+ chunks: 'all',
+ },
+ }
: {},
- }
+ };
};