Author: lf666ksi1vgz

  • gulp-requirejs

    gulp-requirejs

    gulp-requirejs on npm Build Status Coverage

    Information

    A small, simple, very easy wrapper around the require.js optimizer to work with gulp.js.

    Packagegulp-requirejs
    Description uses require.js’s r.js optimizer to combine require.js AMD modules into one file
    Node Version ≧ 4

    Installation

    Simply add gulp-requirejs as a dev-dependency in your package.json or run

    $ npm install --save-dev gulp-requirejs

    Usage

    Because the require.js optimizer (r.js) is a kind of build system in itself we can’t use the gulp.src([...]) syntax at the moment (I might add this in future), instead this wrapper itself emits a pipable stream, holding a ‘virtual’ file, in which the result of the r.js build process are saved.

    The resulting stream can be treated like a regular gulp.src(...) stream.

    NOTE: The built in minification/obfuscation is deactivated by default. It is recommended to use a gulp plugin like gulp-uglify for minification, but you can enable r.js minification by setting the optimize option to uglify to minify using r.js.

    var gulp = require('gulp'),
        rjs = require('gulp-requirejs');
    
    gulp.task('requirejsBuild', function() {
        return rjs({
            baseUrl: 'root/directory/of/js/files/',
            out: 'FILENAME_TO_BE_OUTPUTTED',
            name: 'mainfile', // no extension
            shim: {
                // standard require.js shim options
            },
            // ... more require.js options
        })
        .pipe(gulp.dest('./deploy/')); // pipe it to the output DIR
    });

    If you use instead of out the dir option, you do not need the pipe at all, see this example in Gulp 4 syntax and mocha test:

    const rjs = require('gulp-requirejs');
    
    async function requirejsBuild(cb) {
        return rjs({
            dir: 'deploy',
            mainConfigFile: 'config.js',
            path: {
              'config': '../config_init'
            },
            modules: [{
              name: 'FILENAME_TO_BE_OUTPUTTED', // no extension
              include  : [ .. ]
             ...
            }]
        }) ...
    };
        
    exports.requirejsBuild = requirejsBuild;

    Note: In order to let gulp know that the optimization completes, return the rjs stream.

    See requirejs.org for more information about the supported parameters.

    Error handling

    gulp-requirejs will emit errors when you don’t pass an options object, if the baseUrl or out properties are undefined or when the requirejs optimizer detects an error.

    Source maps

    When source maps are enabled via the r.js generateSourceMaps option the file in the stream rjs() contains a sourceMap property with the sourcemap as an object.

    Use gulp-sourcemaps to process this object in your gulp configuration.

    var gulp = require('gulp'),
        rjs = require('gulp-requirejs')
        sourcemaps = require('gulp-sourcemaps');
    
    gulp.task('requirejsBuild', function() {
        return rjs({
            baseUrl: 'root/directory/of/js/files/',
            out: 'FILENAME_TO_BE_OUTPUTTED',
            name: 'mainfile', // no extension
            generateSourceMaps: true,
            shim: {
                // standard require.js shim options
            },
            // ... more require.js options
        })
        .pipe(sourcemaps.init({loadMaps: true})) // initialize gulp-sourcemaps with the existing map
        .pipe(sourcemaps.write()) // write the source maps
        .pipe(gulp.dest('./deploy/')); // pipe it to the output DIR
    });

    Options

    The options object supports the same parameters as the require.js optimizer.

    Visit original content creator repository https://github.com/jorrit/gulp-requirejs
  • ms-clamav-file-lander

    File submission micro service

    This micro-service handles file submissions from the Citizen. The implementation compress ClamAV
    is a free software, cross-platform and open-source antivirus, and a SpringBoot application serving as a bridge service
    between ClamAV to an outside container, as well as AWS services.

    Rest API

    The service API definition can be found openapi-spec-api.yaml

    Build a docker image with ClamAv and SpringBoot application from scratch

    mvn clean verify
    docker build -t <img-tag-name> . 

    to run the image

    docker run -p 9000:8080 <img-tag-name>

    How it works

    curl -v -H "Content-Type:multipart/form-data" 
    -F "meta=\"{"id": "123", "fileName": "pom.xml", "mime": "plain/txt", "sizeKb": 128, "checksum": "checksum_string", "persist": false }\";type=application/json" 
    -F "file=@{file}" -X POST "http://localhost:8080/v1/scan/upload"

    Virus scan only Request and Response

    Request body for virus scan only. No file persist required

    {
      "id": "such as a claim id",
      "fileName": "image.jpg",
      "mime": "image/jpg",
      "sizeKb": 128,
      "checksum": "string",
      "persist": false
    }
    Success response body – status 200, no virus detected and file persistence not required

    {
      "message": null,
      "s3Ref": null,
      "bucket": null
    }
    Fail response body – status 406 (virus detected)

    {
      "message": "VIRUS DETECTED/MULTIPART FAIL"
    }
    Fail response body – status 406 (Unable to open PDF file, file is password protected)

    {
      "message": "PASSWORD PROTECTED"
    }
    Fail response body – status 500 (multipart file upload failure), indicate service fail to receive the file from client

    {
      "message": "MULTIPART FAIL"
    }

    Virus scan and persist file Request and Response

    Request body for virus scan and persist file to a designated S3 bucket

    {
      "id": "such as a claim id",
      "fileName": "image.jpg",
      "mime": "image/jpg",
      "sizeKb": 128,
      "checksum": "string",
      "persist": true
    }
    Success response body – status 200, no virus detected, and file persisted to a designated S3 bucket

    {
      "message": "ALL SUCCESS",
      "s3Ref": "123_PRESCRIPTION.JPG.2020",
      "bucket": "pip-bucket"
    }
    Fail response body – status 406 (virus detected) or status 500 (multipart or s3)

    {
      "message": "VIRUS DETECTED"
    }
    Fail response body – status 500 (multipart file upload failure or s3 upload failure)

    examples

    {
      "message": "MULTIPART FAIL"
    }

    {
      "message" : "S3 FAIL"
    }

    AWS S3

    Submitted and virus checked file persisted into an AWS S3 bucket, if (persist flag in the request set to true)

    Environment variables

    AWS_S3_AWS_REGION=eu-west-2
    AWS_S3_ENDPOINT_OVERRIDE=http://localstack:4566
    AWS_ACCESS_KEY_ID=accesskey
    AWS_S3_BUCKET=bucket-name
    AWS_S3_ENCRYPT_ENABLE=true

    AWS KMS

    File persist in S3 bucket encrypted
    with Crypto

    Environment variables

    AWS_ENCRYPTION_KMS_OVERRIDE=http://ms-mock-kms-service:5678
    AWS_ENCRYPTION_DATA_KEY=secretkey
    AWS_SECRET_ACCESS_KEY=secret

    Virus signature library self-check/update

    ms-clamav-s3-file-submission-service_1  | Thu Jul  9 13:08:34 2020 -> SelfCheck: Database status OK.
    ms-clamav-s3-file-submission-service_1  | Thu Jul  9 13:18:34 2020 -> SelfCheck: Database status OK.
    ....

    Converter service/API external configuration, it is flexible enough to config API based data type a paired API can support

    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[0]_NAME=test-ms-word-pdf
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[0]_URI=http://word2pdf
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[0]_ENDPOINT=/v1/convert/s3
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[0]_TYPES[0]=application/msword
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[0]_TYPES[1]=application/vnd.openxmlformats-officedocument.wordprocessingml.document
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[1]_NAME=test-image-pdf
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[1]_URI=http://img2pdf
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[1]_ENDPOINT=/v1/convert/s3
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[1]_TYPES[0]=image/jpeg
    UK_GOV_DWP_HEALTH_CONVERTER_SERVICES[1]_TYPES[1]=image/png

    File upload size configuration, the service can apply constraints on size of file/request the service allows through configuration variables

    SPRING_SERVLET_MULTIPART_MAX_FILE_SIZE=10MB    
    SPRING_SERVLET_MULTIPART_MAX_REQUEST_SIZE=11MB # total request size including json metadata

    usage

    // configuration
    @Configuration
    public class CVServiceConfigProperties {
      //...
      // inject configuration and look up an API detail by supporting MIME type
      @Autowired
      private CVServiceConfigProperties config;
    
      CVService service = config.findServiceByMimeType("image/jpg");
    }

    System Requirement

    ClamAv requires a minimum of 2GB of RAM to launch safely.

    Initial delay

    The service has an initial delay as ClamAv starts up and is possibly checking/updating the virus library.

    Visit original content creator repository
    https://github.com/dwp/ms-clamav-file-lander

  • zkSync Lite Docs

    GitHub license npm version Follow us!

    zkSync Documentation for the v1 | CHANGELOG

    This repository contains the zkSync documentation hosted at docs.lite.zksync.io/

    Development

    Prerequisites

    A Node.js installation running Node.js version 16.

    Local run

    yarn install --check-cache
    yarn docs:dev

    Development

    CI pipeline will check that the files are formatted according markdownlint founds no issues in document and spelling is correct. Also, there should be no dead links.

    You can check it locally as follows:

    yarn
    yarn md:lint
    yarn cspell

    If cspell doesn’t recognize a word but you’re sure that it’s correct, consider adding it to the cspell-zksync.txt.

    Deployment

    master branch is automatically deployed to https://console.firebase.google.com/u/0/project/zksync-web-docs

    Deploying altogether

    will do:

    • install node modules;
    • prepare, test and build documentation;
    • afterwards all contained into the dist folder will be deployed in form of the static website
    yarn install --check-cache
    yarn docs:build
    yarn firebase deploy

    Extra documentation

    cSpell

    Configuration in cspell.json:

    • version — version of the setting file, always 0.1
    • language — language – current active spelling language
    • words[] — words – list of words to be always considered correct
    • dictionaries[]
    "dictionaryDefinitions": [
        {
          "name": "zksync", "path": "./cspell-zksync.txt"
        }
    ]
    
    {
      "version": "0.1",
      // language - current active spelling language
      "language": "en",
      // words - list of words to be always considered correct
      "words": [],
      "dictionaries": ["typescript", "zksync"],
      //
      "dictionaryDefinitions": [
      {
        "name": "zksync", "path": "./cspell-zksync.txt"
      }
    ]
    }

    ZKsync Ecosystem



    BTW, we’re hiring: See open positions

    License

    zkWallet is distributed under the terms of both the MIT license, and the Apache License (v.2.0).

    See LICENSE-APACHE, LICENSE-MIT for details.

    Visit original content creator repository https://github.com/matter-labs/zksync-lite-docs