Skip to content

Commit

Permalink
Merge pull request #7 from ItsOnlyBinary/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
ItsOnlyBinary authored Dec 7, 2020
2 parents 9b8747d + 8626198 commit e7ef764
Show file tree
Hide file tree
Showing 58 changed files with 9,339 additions and 21,036 deletions.
18 changes: 0 additions & 18 deletions .babelrc

This file was deleted.

3 changes: 3 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
> 1%
last 2 versions
not dead
8 changes: 3 additions & 5 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
root = true

[*]
charset = utf-8
[*.{js,jsx,ts,tsx,vue}]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
6 changes: 0 additions & 6 deletions .eslintignore

This file was deleted.

80 changes: 31 additions & 49 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,40 @@
const rulesDirPlugin = require('eslint-plugin-rulesdir');
rulesDirPlugin.RULES_DIR = 'config/eslint/rules/';

module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
env: {
node: true,
},
extends: [
'airbnb-base',
'plugin:vue/recommended',
'standard'
'plugin:vue/essential',
'@vue/airbnb',
],
env: {
'browser': true,
parserOptions: {
parser: 'babel-eslint',
},
// required to lint *.vue files
plugins: [
'rulesdir',
'vue',
],
// add your custom rules here
'rules': {
// 'rulesdir/class-name-prefix': 'warn',
'class-methods-use-this': 0,
'comma-dangle': ['error', {
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'never',
'exports': 'never',
'functions': 'ignore'
}],
'import/extensions': 0,
'import/no-extraneous-dependencies': 0,
'import/no-unresolved': 0,
'import/prefer-default-export': 0,
'indent': ['error', 4],
'no-continue': 0,
'no-multi-assign': 0,
'no-param-reassign': ['error', { 'props': false }],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
indent: ['error', 4],
'no-plusplus': 0,
'no-prototype-builtins': 0,
'prefer-promise-reject-errors': 0,
'no-control-regex': 0,
'object-shorthand': 0,
'operator-linebreak': 0,
'operator-linebreak': ['error', 'after'],
// Temp
'prefer-const': 0,
'arrow-parens': 0,
'prefer-destructuring': 0,
'prefer-template': 0,
'semi': ['error', 'always'],
'space-before-function-paren': ['error', 'never'],
'vue/html-indent': ['error', 4],
'vue/max-attributes-per-line': 0,
'vue/require-prop-types': 0,
'vue/require-default-prop': 0,
}
}
'no-underscore-dangle': 0,
'object-shorthand': 0,
'no-param-reassign': 0,
'max-classes-per-file': 0,

},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)',
],
env: {
jest: true,
},
},
],
};
16 changes: 11 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
.DS_Store
node_modules/
/dist/
node_modules
/dist
/backend/configs

# local env files
.env.local
.env.*.local

# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
/test/unit/coverage/
/test/e2e/reports/
selenium-debug.log
pnpm-debug.log*

# Editor directories and files
.idea
Expand All @@ -15,3 +20,4 @@ selenium-debug.log
*.ntvs*
*.njsproj
*.sln
*.sw?
10 changes: 0 additions & 10 deletions .postcssrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# .gitignore syntax (uses node-ignore behind the scenes)
9 changes: 9 additions & 0 deletions .stylelintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
root: true,
extends: [
'stylelint-config-standard',
],
rules: {
indentation: 4,
},
};
43 changes: 21 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
# client-builder

> A Vue.js project
## Build Setup

``` bash
# install dependencies
npm install

# serve with hot reload at localhost:8080
npm run dev

# build for production with minification
npm run build
## Project setup
```
yarn install
```

# build for production and view the bundle analyzer report
npm run build --report
### Compiles and hot-reloads for development
```
yarn dev
```

# run unit tests
npm run unit
### Compiles and minifies for production
```
yarn build
```

# run e2e tests
npm run e2e
### Run your unit tests
```
yarn test:unit
```

# run all tests
npm test
### Lints and fixes files
```
yarn lint
```

For a detailed explanation on how things work, check out the [guide](http://vuejs-templates.github.io/webpack/) and [docs for vue-loader](http://vuejs.github.io/vue-loader).
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset',
],
};
12 changes: 12 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "client-builder-backend",
"version": "1.0.0",
"main": "server.js",
"license": "Unknown",
"private": true,
"dependencies": {
"koa": "^2.13.0",
"koa-body": "^4.2.0",
"koa-router": "^9.4.0"
}
}
76 changes: 76 additions & 0 deletions backend/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
const fs = require('fs');
const crypto = require('crypto');

const Koa = require('koa');
const koaBody = require('koa-body');
const Router = require('koa-router');

const host = '127.0.0.1';
const port = 8181;
const path = '/client-builder';
const store = './configs';

const app = new Koa();
const router = new Router();

if (!fs.existsSync(store)) {
fs.mkdirSync(store);
}

app.use(koaBody({ multipart: true, includeUnparsed: true }));
app.use(async (ctx, next) => {
ctx.set('Access-Control-Allow-Origin', '*');
ctx.set('Access-Control-Allow-Headers', 'x-auth-token');
await next();
});
app.use(router.routes());
app.use(router.allowedMethods());

router.post(`${path}/save`, async (ctx) => {
let id = false; // Object.keys(ctx.request.query)[0];

ctx.response.status = 500;
ctx.response.body = { error: 'Error saving settings' };

if (typeof ctx.request.body !== 'object') {
ctx.response.status = 400;
return;
}

if (!id || id.length !== 32) {
id = crypto.randomBytes(16).toString('hex');
}

await fs.promises.writeFile(`configs/${id}.json`, JSON.stringify(ctx.request.body))
.then(() => {
ctx.response.status = 201;
ctx.response.body = { status: 'success', settings_id: id };
})
.catch((err) => {
console.log('save error:', err);
});
});

router.get(`${path}`, async (ctx) => {
let id = ctx.request.query.settings;

ctx.response.status = 500;
ctx.response.body = { error: 'Bad request' };

if (!id || id.length !== 32) {
return;
}

await fs.promises.readFile(`configs/${id}.json`)
.then((data) => {
ctx.response.status = 200;
ctx.response.body = JSON.parse(data);
})
.catch((err) => {
console.log('read error:', err);
});
});

app.listen(port, host, () => {
console.log(`Server running at http://${host}:${port}/`);
});
Loading

0 comments on commit e7ef764

Please sign in to comment.