我有一个库,它具有基于某些字段过滤对象的功能(每个字段都有特定类型的类型 - 有关https://github.com/jy95/mediaScan/wiki 的更多信息)
最大的问题是处理来自多个来源的数字属性
// to handle number operations
export interface NumberExpressionObject {
operator: "==" | ">" | "<" | ">=" | "<=";
number: number;
}
// additional Properties
export interface AdditionalProperties {
type: AdditionalPropertiesType;
name: string;
value: boolean | string | string[] | number | NumberSearchSyntax;
}
Run Code Online (Sandbox Code Playgroud)
例如 :
expect((libInstance.filterTvSeries({
additionalProperties: [
{type: "number", name: "whateverFieldThatDoesn'tExist", value: "<50"},
{type: "number", name: "AnotherField", value: undefined},
{type: "number", name: "AnotherField2", value: "<=25"},
{type: "number", name: "AnotherField3", value: ">25"}, …Run Code Online (Sandbox Code Playgroud) 我为 CI/CD 设置了 Github Actions,但我在数据库连接方面遇到了困难。
由于sequelize允许指定另一个数据库url(使用“use_env_variable”选项),我更新了我的配置,如下所示:
{
"test": {
"dialect": "postgres",
"schema": "exercises_library",
"logging": false,
"use_env_variable": "DATABASE_URL"
},
"production": {
"dialect": "postgres",
"schema": "exercises_library",
"logging": false,
"use_env_variable": "DATABASE_URL"
}
}
Run Code Online (Sandbox Code Playgroud)
所以我在 Github Actions 中编写了我的工作流程:
name: Source Code CI/CD
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
ci:
runs-on: ubuntu-latest
container:
image: node:12
services:
# More explanation about that here :
# https://github.com/actions/example-services/blob/master/.github/workflows/postgres-service.yml
postgres:
image: postgres:12-alpine
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: jy95
POSTGRES_DB: sourcecode
ports: ["5432:5432"]
options: --health-cmd pg_isready --health-interval …Run Code Online (Sandbox Code Playgroud) 我在 Nodejs 上使用了这个模块:https : //github.com/bpampuch/pdfmake
这是我创建它的代码:
const fonts = {
Roboto: {
normal: './fonts/Roboto-Regular.ttf',
bold: './fonts/Roboto-Medium.ttf',
italics: './fonts/Roboto-Italic.ttf',
bolditalics: './fonts/Roboto-Italic.ttf'
}
};
let PdfPrinter = require('pdfmake/src/printer');
let printer = new PdfPrinter(fonts);
let fs = require('fs');
module.exports.generateFile = function (data,callback) {
let fileName = "Logins_" + data[0]["userLogin"] + ".pdf";
let filePath = __dirname + "/files/" + fileName;
let logins = [ ['userLogin', 'softwarePassword', 'softwareName'] ];
for (let obj of data) {
let arr = [];
for(let x in obj){
arr.push(obj[x]); …Run Code Online (Sandbox Code Playgroud) node.js ×3
eval ×1
javascript ×1
pdf ×1
pdfmake ×1
postgresql ×1
sequelize.js ×1
typescript ×1