Skip to content

Commit

Permalink
feat: add meta table
Browse files Browse the repository at this point in the history
  • Loading branch information
frantzarty committed Jan 19, 2022
1 parent d7666fe commit ecec61b
Show file tree
Hide file tree
Showing 9 changed files with 588 additions and 0 deletions.
473 changes: 473 additions & 0 deletions docs/postman/Projects API.postman_collection.json

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions docs/postman/chia-localhost.postman_environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"id": "e81565ef-0d7a-4335-8588-96e2cebe5541",
"name": "chia-localhost",
"values": [
{
"key": "api_url_v1",
"value": "http://localhost:3001/v1",
"enabled": true
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2022-01-19T19:56:07.283Z",
"_postman_exported_using": "Postman/9.9.3"
}
13 changes: 13 additions & 0 deletions migrations/20220119211024-create-meta-table.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

const modelTypes = require('../src/models/meta/meta.modeltypes.cjs');

module.exports = {
async up(queryInterface) {
await queryInterface.createTable('meta', modelTypes);
},

async down(queryInterface) {
await queryInterface.dropTable('meta');
},
};
47 changes: 47 additions & 0 deletions src/fullnode/datalayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import fs from 'fs';
import path from 'path';
import request from 'request';

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

const certFile = path.resolve(
`${process.env.CHIA_ROOT}/config/ssl/data_layer/private_data_layer.crt`,
);
const keyFile = path.resolve(
`${process.env.CHIA_ROOT}/config/ssl/data_layer/private_data_layer.key`,
);

const rpcUrl = process.env.DATALAYER_URL;

const baseOptions = {
method: 'POST',
cert: fs.readFileSync(certFile),
key: fs.readFileSync(keyFile),
};

export const pushChangeListToDatalayer = (changeList) => {
return new Promise((resolve, reject) => {
const options = {
url: `${rpcUrl}/update_data_store`,
body: JSON.stringify({
changelist: changeList,
id: 'c19cfd5a1f0a221976debcd1206daca0a07bf5e949949c2f30488562870a2fff',
}),
};

console.log(changeList);

request(
Object.assign({}, baseOptions, options),
function (error, response) {
if (error) {
console.log('!!!!!!');
reject(error);
return;
}
console.log(response.body);
resolve(response);
},
);
});
};
2 changes: 2 additions & 0 deletions src/models/meta/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './organizations.model.js';
export * from './organizations.mock.js';
8 changes: 8 additions & 0 deletions src/models/meta/meta.mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import stub from './organizations.stub.json';

export const CoBenefitsMock = {
findAll: () => stub,
findOne: (id) => {
return stub.find((record) => record.id == id);
},
};
16 changes: 16 additions & 0 deletions src/models/meta/meta.model.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

import Sequelize from 'sequelize';
const { Model } = Sequelize;
import { sequelize } from '../database';

import ModelTypes from './meta.modeltypes.cjs';

class Meta extends Model {}

Meta.init(ModelTypes, {
sequelize,
modelName: 'meta',
});

export { Meta };
14 changes: 14 additions & 0 deletions src/models/meta/meta.modeltypes.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const Sequelize = require('sequelize');

module.exports = {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
},
meta_key: {
type: Sequelize.STRING,
unique: true,
},
meta_value: Sequelize.STRING,
};
1 change: 1 addition & 0 deletions src/models/meta/meta.stub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]

0 comments on commit ecec61b

Please sign in to comment.