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

feat: bun init #3387

Closed
wants to merge 4 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ src/util/eventValidations.js
src/v0/destinations/personalize/scripts/
test/integrations/destinations/testTypes.d.ts
*.config*.js
scripts/skipPrepareScript.js
scripts/skipPrepareScript.js
71 changes: 71 additions & 0 deletions bunRuntime/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
{
"env": {
"node": true,
"es2021": true,
"jest": true,
"commonjs": true
},
"extends": [
"airbnb-base",
"airbnb-typescript/base",
"plugin:sonarjs/recommended",
"plugin:json/recommended",
"plugin:@typescript-eslint/recommended",
"prettier"
],
"plugins": ["@typescript-eslint", "unicorn"],
"globals": {},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module",
"project": "./tsconfig.json"
},
"rules": {
"unicorn/filename-case": [
"off",
{ "cases": { "camelCase": true, "pascalCase": true, "kebabCase": true } }
],
"import/no-import-module-exports": "off",
"unicorn/no-instanceof-array": "error",
"unicorn/no-static-only-class": "error",
"unicorn/consistent-destructuring": "error",
"unicorn/better-regex": "error",
"unicorn/no-for-loop": "error",
"unicorn/prefer-array-some": "error",
"unicorn/explicit-length-check": "error",
"unicorn/prefer-array-find": "error",
"unicorn/no-lonely-if": "error",
"unicorn/prefer-includes": "error",
"unicorn/prefer-array-flat-map": "error",
"unicorn/no-useless-spread": "error",
"unicorn/no-useless-length-check": "error",
"unicorn/prefer-export-from": "error",
"import/no-dynamic-require": "error",
"no-param-reassign": "error",
"sonarjs/prefer-immediate-return": "off",
"sonarjs/no-nested-template-literals": "off",
"sonarjs/max-switch-cases": "error",
"sonarjs/no-small-switch": "error",
"sonarjs/cognitive-complexity": ["error", 60],
"@typescript-eslint/no-var-requires": "off",
"global-require": "error",
"@typescript-eslint/naming-convention": "error",
"@typescript-eslint/ban-types": "error",
"@typescript-eslint/no-explicit-any": "off",
"class-methods-use-this": "off",
"@typescript-eslint/return-await": "error",
"import/prefer-default-export": "off",
"sonarjs/no-ignored-return": "error",
"no-new": "error",
"@typescript-eslint/no-shadow": "error",
"@typescript-eslint/no-loop-func": "error",
"sonarjs/no-same-line-conditional": "error",
"no-restricted-syntax": "error",
"sonarjs/no-duplicate-string": "error",
"sonarjs/no-identical-functions": "error",
"no-prototype-builtins": "off",
"@typescript-eslint/dot-notation": "error",
"@typescript-eslint/no-unused-vars": "error"
}
}
42 changes: 42 additions & 0 deletions bunRuntime/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

**/*.trace
**/*.zip
**/*.tar.gz
**/*.tgz
**/*.log
package-lock.json
**/*.bun
15 changes: 15 additions & 0 deletions bunRuntime/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Elysia with Bun runtime

## Getting Started
To get started with this template, simply paste this command into your terminal:
```bash
bun create elysia ./elysia-example
```

## Development
To start the development server run:
```bash
bun run dev
```

Open http://localhost:3000/ with your browser to see the result.
Binary file added bunRuntime/bun.lockb
Binary file not shown.
196 changes: 196 additions & 0 deletions bunRuntime/k6test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
import { check } from "k6";
import http from "k6/http";

// check out how to get node libraries into k6
import { uuidv4 } from "https://jslib.k6.io/k6-utils/1.4.0/index.js";

// Prefer ramping arrival rate for proper/heavy load tests.
export const options = {
scenarios: {
scenario1: {
executor: "constant-arrival-rate",
duration: "30s",
rate: 300,
timeUnit: "1s",
preAllocatedVUs: 100,
maxVUs: 300,
exec: "scenario1",
},
},
};

const hostUrl = "http://gateway.openfaas-anshul.svc.cluster.local:8080";
const url = `${hostUrl}/function`;

// See additional resources uploaded below.
const base_msgs = {
message: {
name: "search_list",
type: "page",
sentAt: "2023-05-18T10:16:31.668Z",
userId: "",
channel: "web",
context: {
os: {
name: "",
version: "",
},
app: {
name: "RudderLabs JavaScript SDK",
version: "2.33.1",
namespace: "com.rudderlabs.javascript",
},
page: {
url: "/au/hoka-one-one/shop/category/clothing-shoes-accessories-women-37964/?page=1&dsp=hidden",
path: "/au/hoka-one-one/shop/category/clothing-shoes-accessories-women-37964/",
title: "Buy Hoka One One Women's Shoes Online | Kogan",
search: "?page=1&dsp=hidden",
tab_url:
"https://www.kogan.com/au/hoka-one-one/shop/category/clothing-shoes-accessories-women-37964/?page=1&dsp=hidden",
referrer: "https://www.kogan.com/",
initial_referrer: "https://www.google.com/",
referring_domain: "www.kogan.com",
initial_referring_domain: "www.google.com",
},
locale: "en-GB",
screen: {
width: 1440,
height: 900,
density: 2,
innerWidth: 1440,
innerHeight: 628,
},
traits: {},
library: {
name: "RudderLabs JavaScript SDK",
version: "2.33.1",
},
campaign: {},
sessionId: 1684404970769,
userAgent:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
},
rudderId: "2d11e550-950c-4269-a2c4-1b7c9b9986f6",
messageId: "18495590-48af-4361-8daf-7590254dc798",
properties: {
url: "/au/hoka-one-one/shop/category/clothing-shoes-accessories-women-37964/?page=1&dsp=hidden",
name: "search_list",
path: "/au/hoka-one-one/shop/category/clothing-shoes-accessories-women-37964/",
title: "Buy Hoka One One Women's Shoes Online | Kogan",
search: "?page=1&dsp=hidden",
tab_url:
"https://www.kogan.com/au/hoka-one-one/shop/category/clothing-shoes-accessories-women-37964/?page=1&dsp=hidden",
referrer: "https://www.kogan.com/",
initial_referrer: "https://www.google.com/",
referring_domain: "www.kogan.com",
initial_referring_domain: "www.google.com",
},
anonymousId: "b87bbb52-478b-4043-ad77-7f26a9a5d54f",
integrations: {
All: true,
"Google Analytics 4": {
clientId: "1987030102.1683088628",
sessionId: "1684404975",
sessionNumber: 1,
},
},
originalTimestamp: "2023-05-18T10:16:31.654Z",
},
metadata: {
sourceId: "abcdFB7XK",
namespace: "abcd",
instanceId: "abcd-v0-rs-0",
sourceType: "PHP",
sourceCategory: "",
destinationId: "abcdT9Ri",
jobRunId: "",
jobId: 177608976,
sourceBatchId: "",
sourceJobId: "",
sourceJobRunId: "",
sourceTaskId: "",
sourceTaskRunId: "",
recordId: null,
destinationType: "RS",
messageId: "93f09dd2-2655-4064-8926-b2b13e40449f",
messageIds: null,
rudderId: "7b4b4c21-7a58-40d5-be6e-887b75d31544",
receivedAt: "2021-12-20T10:19:19.387Z",
eventName: "page-viewed",
eventType: "page",
sourceDefinitionId: "abcdIpansx2",
destinationDefinitionId: "",
trackingPlanId: "tp_2eavhhgNSrhVJoPuXdyqOht5Adt",
trackingPlanVersion: "3",
"workspaceId": "1z8QUcZx49fzs4V3wIqNJRH0emr",
"mergedTpConfig": {
"allowUnplannedEvents": "false",
"unplannedProperties": "drop",
"anyOtherViolation": "drop",
"sendViolatedEventsTo": "procErrors",
"ajvOptions": {}
},
"sourceTpConfig": {
"track": {
"allowUnplannedEvents": "true",
"unplannedProperties": "forward",
"anyOtherViolation": "forward",
"propagateValidationErrors": "true",
"ajvOptions": {}
},
"global": {
"allowUnplannedEvents": "false",
"unplannedProperties": "drop",
"anyOtherViolation": "drop",
"sendViolatedEventsTo": "procErrors",
"ajvOptions": {}
}
}
},
destination: {
ID: "abcdT9Ri",
Name: "redshift",
Enabled: true,
Transformations: [
{
VersionID: "2bnkuhqMkU8BX0FTryBgBrHaFIB",
ID: "abcdyhNM",
Config: {},
},
],
IsProcessorEnabled: true,
},
libraries: [],
};

// Looks like some batching logic that I don't remember clearly myself.
// Not necessary for simple load tests.
export function setup() {
const payloads = [];

for (let j = 0; j < 30; j += 1) {
let baseMsgs = base_msgs;
baseMsgs.message.messageId = uuidv4();
baseMsgs.metadata.messageId = uuidv4();
payloads.push(baseMsgs);
}

return { payloads };
}

export function scenario1(data) {
const { payloads } = data;
const functionUrl = `${url}/${__ENV.FUNCTION}`.trim();

const response = http.post(functionUrl, JSON.stringify(payloads), {
headers: { "Content-Type": "application/json" },
});

check(response, {
"transformation success": (r) => {
r.status !== 200 && console.log(r.status);

return r.status === 200;
},
});
}
Loading
Loading