Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package maitenance #294

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .eslintrc.json

This file was deleted.

4 changes: 1 addition & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: Testing CI

on: pull_request

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -12,13 +10,13 @@ jobs:
- 18
- 20
- 21
- 22
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
Expand Down
10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

15 changes: 15 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const init = require('eslint-config-metarhia');

module.exports = [
...init,
{
files: ['lib/plugins/*.js'],
languageOptions: {
globals: {
db: true,
},
},
},
];
5 changes: 5 additions & 0 deletions lib/plugins/crud.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,36 @@ module.exports = (init) => () => {
for (const [entity, methods] of Object.entries(entities)) {
if (methods.includes('create')) {
unit['create' + entity] = (context) => async (record) => {
if (!context) throw new Error('Cant execute CREATE');
const result = await database.insert(entity, record);
return { result };
};
}
if (methods.includes('get')) {
unit['get' + entity] = (context) => async (conditions) => {
if (!context) throw new Error('Cant execute GET');
const result = await database.row(entity, conditions);
return { result };
};
}
if (methods.includes('select')) {
unit['select' + entity] = (context) => async (conditions) => {
if (!context) throw new Error('Cant execute SELECT');
const result = await database.select(entity, conditions);
return { result };
};
}
if (methods.includes('update')) {
unit['update' + entity] = (context) => async (args) => {
if (!context) throw new Error('Cant execute UPDATE');
const { delta, conditions } = args;
const result = await database.update(entity, delta, conditions);
return { result };
};
}
if (methods.includes('delete')) {
unit['delete' + entity] = (context) => async (conditions) => {
if (!context) throw new Error('Cant execute DELETE');
const result = await database.delete(entity, conditions);
return { result };
};
Expand Down
Loading
Loading