Skip to content
Open
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
29 changes: 0 additions & 29 deletions .eslintrc

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/release-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '22.x'
registry-url: 'https://registry.npmjs.org'
- name: Set up Ruby
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install ImageMagick
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x]
node-version: [20.x, 22.x]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Set up Ruby
uses: ruby/setup-ruby@359bebbc29cbe6c87da6bc9ea3bc930432750108
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7

Expand Down
2 changes: 2 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{
"node-option": ["import=tsx"],
"spec": ["tests/helpers.ts", "tests/**/*.spec.ts"]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16-alpine as builder
FROM node:20-alpine as builder

WORKDIR /home/app

Expand Down
84 changes: 84 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import globals from 'globals';
import noOnlyTests from 'eslint-plugin-no-only-tests';
import chaiFriendly from 'eslint-plugin-chai-friendly';

const consoleLogRule = process.env.NODE_ENV === 'production' ? ['error', { allow: ['warn', 'error'] }] : ['warn'];

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
plugins: {
'no-only-tests': noOnlyTests,
'chai-friendly': chaiFriendly,
},
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
...globals.es2021,
},
parserOptions: {
sourceType: 'module',
},
},
rules: {
// Rules from @enspirit/eslint-config-node
'prefer-template': 'warn',
'template-curly-spacing': ['error', 'never'],
'curly': 'error',
'prefer-arrow-callback': 'warn',
'no-useless-escape': 'warn',
'eqeqeq': 'error',
'no-multi-spaces': ['warn', {
exceptions: {
'Property': true,
'VariableDeclarator': true,
'ImportDeclaration': true,
},
}],
'indent': ['error', 2, { SwitchCase: 1 }],
'linebreak-style': ['error', 'unix'],
'quotes': ['error', 'single', { avoidEscape: true }],
'semi': ['error', 'always'],
'no-var': ['error'],
'prefer-const': ['error'],
'no-console': consoleLogRule,
'no-debugger': 'error',
'no-unused-expressions': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'chai-friendly/no-unused-expressions': ['error'],
'array-bracket-spacing': ['error', 'never'],
'object-curly-spacing': ['error', 'always'],
'space-before-function-paren': ['error', {
anonymous: 'never',
named: 'never',
asyncArrow: 'always',
}],
'space-before-blocks': ['error', 'always'],
'keyword-spacing': ['error', { before: true, after: true }],
'space-infix-ops': ['error', { int32Hint: false }],
'space-in-parens': ['error', 'never'],
'arrow-spacing': ['error', { before: true, after: true }],
'no-multiple-empty-lines': ['error', { max: 1 }],
'no-const-assign': ['error'],
'comma-dangle': ['error', 'always-multiline'],
'no-only-tests/no-only-tests': process.env.NODE_ENV === 'test' ? 'error' : 'warn',

// TypeScript overrides
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', {
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
}],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
},
},
{
ignores: ['dist/**', 'node_modules/**'],
},
);
8 changes: 4 additions & 4 deletions examples/actions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Express } from 'express';
import { createApp, LocalBucket, S3Bucket } from '../src';
import { MkdirAction, DownloadArchiveAction, CleanupTTL } from '../src/actions';
import { ExecuteActions, MultipartUpload, RetrieveObjects } from '../src/';
import { s3client } from './s3';
import { createApp, LocalBucket, S3Bucket } from '../src/index.js';
import { MkdirAction, DownloadArchiveAction, CleanupTTL } from '../src/actions/index.js';
import { ExecuteActions, MultipartUpload, RetrieveObjects } from '../src/index.js';
import { s3client } from './s3.js';

/**
* This example shows how actions can be executed on a bucket.
Expand Down
4 changes: 2 additions & 2 deletions examples/authentication.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Express, NextFunction, Request, Response } from 'express';
import { createApp, S3Bucket } from '../src';
import { s3client } from './s3';
import { createApp, S3Bucket } from '../src/index.js';
import { s3client } from './s3.js';

/**
* This simple example shows how you can setup a middleware to
Expand Down
2 changes: 1 addition & 1 deletion examples/cacheControl.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Express } from 'express';
import { createApp, DeleteObjects, LocalBucket, MultipartUpload, RetrieveObjects } from '../src';
import { createApp, DeleteObjects, LocalBucket, MultipartUpload, RetrieveObjects } from '../src/index.js';

/**
* This simple example shows how to override the default
Expand Down
6 changes: 3 additions & 3 deletions examples/clamav.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Express } from 'express';
import { createApp, LocalBucket, S3Bucket } from '../src';
import { ClamavScanner } from '../src/transformers';
import { s3client } from './s3';
import { createApp, LocalBucket, S3Bucket } from '../src/index.js';
import { ClamavScanner } from '../src/transformers/index.js';
import { s3client } from './s3.js';

/**
* This example shows how a bucket can use the clamav transformer
Expand Down
2 changes: 1 addition & 1 deletion examples/gcs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Express } from 'express';
import { createApp, GCSBucket } from '../src';
import { createApp, GCSBucket } from '../src/index.js';
import { Storage } from '@google-cloud/storage';

/**
Expand Down
6 changes: 3 additions & 3 deletions examples/gzip.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Express } from 'express';
import { createApp, S3Bucket } from '../src';
import { ObjectCompressor } from '../src/transformers';
import { s3client } from './s3';
import { createApp, S3Bucket } from '../src/index.js';
import { ObjectCompressor } from '../src/transformers/index.js';
import { s3client } from './s3.js';

/**
* This simple example shows how a bucket can use object transformers.
Expand Down
30 changes: 15 additions & 15 deletions examples/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import express, { NextFunction, Request, Response } from 'express';

import localExample from './local';
import s3example from './s3';
import gcsexample from './gcs';
import gzipExample from './gzip';
import authenticationExample from './authentication';
import readOnlyExample from './readonly';
import renameExample from './rename';
import thumbnailsExample from './thumbnails';
import thumbnailsOnTheFlyExample from './thumbnails-on-the-fly';
import actionsExample from './actions';
import sseExample from './sse-c';
import clamavExample from './clamav';
import cacheControlExample from './cacheControl';
import localExample from './local.js';
import s3example from './s3.js';
import gcsexample from './gcs.js';
import gzipExample from './gzip.js';
import authenticationExample from './authentication.js';
import readOnlyExample from './readonly.js';
import renameExample from './rename.js';
import thumbnailsExample from './thumbnails.js';
import thumbnailsOnTheFlyExample from './thumbnails-on-the-fly.js';
import actionsExample from './actions.js';
import sseExample from './sse-c.js';
import clamavExample from './clamav.js';
import cacheControlExample from './cacheControl.js';

import { version } from '../src';
import logger from '../src/logger';
import { version } from '../src/index.js';
import logger from '../src/logger.js';

const app = express();
app.set('etag', 'strong');
Expand Down
2 changes: 1 addition & 1 deletion examples/local.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Express } from 'express';
import { createApp, LocalBucket } from '../src';
import { createApp, LocalBucket } from '../src/index.js';

/**
* This simple example shows how to add a seshat endpoint
Expand Down
4 changes: 2 additions & 2 deletions examples/readonly.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Express } from 'express';
import { createApp, LocalBucket } from '../src';
import { ReadOnlyPolicy } from '../src';
import { createApp, LocalBucket } from '../src/index.js';
import { ReadOnlyPolicy } from '../src/index.js';

/**
* This simple example shows how a bucket can use policies to allow/disallow actions.
Expand Down
6 changes: 3 additions & 3 deletions examples/rename.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Express } from 'express';
import { createApp, S3Bucket } from '../src';
import { SecureRename } from '../src/transformers';
import { s3client } from './s3';
import { createApp, S3Bucket } from '../src/index.js';
import { SecureRename } from '../src/transformers/index.js';
import { s3client } from './s3.js';

/**
* This simple example shows how a bucket can use policies to allow/disallow actions.
Expand Down
2 changes: 1 addition & 1 deletion examples/s3.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Express } from 'express';
import { createApp, S3Bucket } from '../src';
import { createApp, S3Bucket } from '../src/index.js';
import { S3Client } from '@aws-sdk/client-s3';

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/sse-c.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Express } from 'express';
import { createApp, S3Bucket } from '../src';
import { createApp, S3Bucket } from '../src/index.js';
import { S3Client } from '@aws-sdk/client-s3';

/**
Expand Down
8 changes: 4 additions & 4 deletions examples/thumbnails-on-the-fly.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Express } from 'express';
import { createApp, S3Bucket } from '../src';
import { SharpTransformer } from '../src/transformers/sharp';
import { s3client } from './s3';
import { createApp, S3Bucket } from '../src/index.js';
import { SharpTransformer } from '../src/transformers/sharp.js';
import { s3client } from './s3.js';

// Reuse the policy from the other example
import { imagesOnlyPolicy } from './thumbnails';
import { imagesOnlyPolicy } from './thumbnails.js';

/**
* This example is similar to the 'thumbnails' example as it combines a custom policy
Expand Down
6 changes: 3 additions & 3 deletions examples/thumbnails.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Express } from 'express';
import { BucketPolicy, BucketPolicyError, createApp, ObjectMeta, S3Bucket } from '../src';
import { SharpTransformer } from '../src/transformers/sharp';
import { s3client } from './s3';
import { type BucketPolicy, BucketPolicyError, createApp, type ObjectMeta, S3Bucket } from '../src/index.js';
import { SharpTransformer } from '../src/transformers/sharp.js';
import { s3client } from './s3.js';

export const imagesOnlyPolicy: BucketPolicy = {
async head(_path: string) {
Expand Down
4 changes: 2 additions & 2 deletions formaldoc/test-suite/bucket-storages/gcs/_prefix/get.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

input_schema: |-
{
prefix : String
prefix : String|Nil
}

output_schema: |-
Expand All @@ -31,7 +31,7 @@
- description: |-
FOR: the root prefix exists
params:
prefix: /
prefix:
expected:
content_type: application/json
status: 200
Expand Down
4 changes: 2 additions & 2 deletions formaldoc/test-suite/bucket-storages/s3/_prefix/get.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

input_schema: |-
{
prefix : String
prefix : String|Nil
}

output_schema: |-
Expand All @@ -31,7 +31,7 @@
- description: |-
FOR: the root prefix exists
params:
prefix: /
prefix:
expected:
content_type: application/json
status: 200
Expand Down
Loading
Loading