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
12 changes: 6 additions & 6 deletions docs/advance/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Deploy your application again and you may now use ElastiCache.

## Cache Usage

Import the `cache` module from `Utils/cache`.
Import the `cache` module from `lesgo/utils/cache`.

To test the sample usage, uncomment `samples.yml` function in `serverless.yml` and deploy the application to a development environment.

Expand All @@ -60,7 +60,7 @@ cache.get(
```

```js
import cache from "Utils/cache";
import cache from "lesgo/utils/cache";

const data = await cache.get("foo");
```
Expand All @@ -78,7 +78,7 @@ cache.getMulti(
**Example Usage**

```js
import cache from "Utils/cache";
import cache from "lesgo/Utils/cache";

const cacheKeys = ["foo", "foo2", "foo3"];

Expand All @@ -90,7 +90,7 @@ const data = await cache.getMulti(["foo", "foo2", "foo3"]);
You may use the `set` method on the `cache` util to store items to the cache.

```js
import cache from "Utils/cache";
import cache from "lesgo/utils/cache";

const cacheKey = "foo";
const cacheValue = "bar";
Expand All @@ -114,7 +114,7 @@ cache.del(
**Example Usage**

```js
import cache from "Utils/cache";
import cache from "lesgo/utils/cache";

await cache.del("foo");
```
Expand All @@ -132,7 +132,7 @@ cache.delMulti(
**Example Usage**

```js
import cache from "Utils/cache";
import cache from "lesgo/utils/cache";

await cache.delMulti(["foo", "foo2", "foo3"]);
```
34 changes: 17 additions & 17 deletions docs/advance/helpers.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Helpers

Lesgo! comes in-built with various helper functions available within the `Utils/` namespace.
Lesgo! comes in-built with various helper functions available within the `lesgo/utils/` namespace.

## Crypto

> `Utils/crypto`
> `lesgo/utils/crypto`

Cryptographic functions using the Crypto npm library.

Expand All @@ -13,7 +13,7 @@ Cryptographic functions using the Crypto npm library.
One way hashing of data using SHA-256.

```js
import { hash } from "Utils/crypto";
import { hash } from "lesgo/utils/crypto";

const hashedString = hash("some data to hash");

Expand All @@ -25,7 +25,7 @@ const hashedString = hash("some data to hash");
One way hashing of data using the faster MD5.

```js
import { hashMD5 } from "Utils/crypto";
import { hashMD5 } from "lesgo/utils/crypto";

const hashedMD5String = hashMD5("some data to hash");

Expand All @@ -41,7 +41,7 @@ const hashedMD5String = hashMD5("some data to hash");
2-way encryption with auto-generated iv and cipher.

```js
import { encrypt } from "Utils/crypto";
import { encrypt } from "lesgo/utils/crypto";

const encryptedStr = encrypt(
"some string to be encrypted that can be decrypted"
Expand All @@ -55,7 +55,7 @@ const encryptedStr = encrypt(
Decrypting a previously encrypted data.

```js
import { decrypt } from "Utils/crypto";
import { decrypt } from "lesgo/utils/crypto";

const decryptedStr = decrypt("some-encrypted-string");

Expand All @@ -64,12 +64,12 @@ const decryptedStr = decrypt("some-encrypted-string");

## Generate Uid

> `Utils/generateUid`
> `lesgo/utils/generateUid`

Generates random string with an optional prefix and suffix using the Nanoid npm library. Useful for generating unique id.

```js
import generateUid from "Utils/generateUid";
import generateUid from "lesgo/utils/generateUid";

const uid = generateUid());

Expand All @@ -90,12 +90,12 @@ const uidLimited = generateUid({ length: 36 }));

## Email Format Validator

> `Utils/isEmail`
> `lesgo/utils/isEmail`

Validates for a valid email format.

```js
import isEmail from "Utils/isEmail";
import isEmail from "lesgo/utils/isEmail";

isEmail("john@doe.com"));

Expand All @@ -108,12 +108,12 @@ isEmail("some string"));

## Decimal Number Validator

> `Utils/isDecimal`
> `lesgo/utils/isDecimal`

Validates for a valid decimal number in any format such as `##.##`.

```js
import isDecimal from "Utils/isDecimal";
import isDecimal from "lesgo/utils/isDecimal";

isDecimal(5.4);

Expand All @@ -126,12 +126,12 @@ isDecimal(5);

## Empty Value Validator

> `Utils/isEmpty`
> `lesgo/utils/isEmpty`

Validates if a value is either an `undefined`, or `null`, or empty string, or an empty array, or an object without keys.

```js
import isEmpty from "Utils/isEmpty";
import isEmpty from "lesgo/utils/isEmpty";

isEmpty(undefined);
isEmpty(null);
Expand All @@ -149,12 +149,12 @@ isEmpty(0);

## Field Validator

> `Utils/validateFields`
> `lesgo/utils/validateFields`

Validates parameters received to ensure the data is of the right type and exists.

```js
import validateFields from "Utils/validateFields";
import validateFields from "lesgo/utils/validateFields";

const validFields = [
{ key: "someString", type: "string", required: true },
Expand Down Expand Up @@ -242,7 +242,7 @@ prepSQLInsertParams(
**Usage**

```js
import prepSQLInsertParams from "Utils/prepSQLInsertParams";
import prepSQLInsertParams from "lesgo/utils/prepSQLInsertParams";

const params = {
username: "John",
Expand Down
2 changes: 1 addition & 1 deletion docs/advance/object-store.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ AWS_S3_OPTIONS_REGION=""
The `getObject()` function will fetch the object from the Bucket.

```js
import { getObject } from 'Utils/objectStore';
import { getObject } from "lesgo/utils/objectStore";

// Returns a buffered object response. See AWS for more information
const objectFile = await getObject('Key', 'Bucket');
Expand Down
2 changes: 1 addition & 1 deletion docs/advance/queues.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The `Utils/dispatch` function will dispatch a message payload to the queue.
This example usage will send a message to the pre-defined PingQueue.

```js
import { dispatch } from "Utils/queue";
import { dispatch } from "lesgo/utils/queue";

const payload = {
someData: "someValue",
Expand Down
2 changes: 1 addition & 1 deletion docs/basics/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SENTRY_RELEASE="sls-my-project-maste"
Call this as early as possible on any of your lambdas. A suggestion would be to put this inside of a middleware

```js
import connectSentry from "Utils/sentry";
import connectSentry from "lesgo/utils/sentry";

connectSentry();
```
2 changes: 1 addition & 1 deletion docs/basics/logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Lesgo! is configured with structured logging.
Structured logs will appear on the console by default.

```js
import logger from "Utils/logger";
import logger from "lesgo/utils/logger";

logger.log("info", "this is an info log");
logger.info("This is an info log");
Expand Down
6 changes: 3 additions & 3 deletions docs/basics/middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This middleware normalizes all HTTP requests, handles, and formats success and e

```js
import middy from '@middy/core';
import httpMiddleware from "Middlewares/httpMiddleware";
import httpMiddleware from "lesgo/middlewares/httpMiddleware";

const originalHandler = event => {
return event.input;
Expand Down Expand Up @@ -74,7 +74,7 @@ This middleware will normalize records coming from sqs message event. The `Recor

```js
import middy from '@middy/core';
import normalizeSQSMessage from "Middlewares/normalizeSQSMessage";
import normalizeSQSMessage from "lesgo/middlewares/normalizeSQSMessage";

const originalHandler = event => {
return event.collection;
Expand Down Expand Up @@ -117,7 +117,7 @@ JWT_CUSTOM_CLAIMS_DATA=""

```js
import middy from '@middy/core';
import verifyJwtTokenMiddleware from "Middlewares/verifyJwtTokenMiddleware";
import verifyJwtTokenMiddleware from "lesgo/middlewares/verifyJwtTokenMiddleware";

const originalHandler = event => {
return event.collection;
Expand Down
8 changes: 4 additions & 4 deletions docs/database/dynamodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dynamodb.query(
**Usage**

```js
import dynamodb from "Utils/dynamodb";
import dynamodb from "lesgo/utils/dynamodb";

const user = await dynamodb.query(
"ActorsTable",
Expand Down Expand Up @@ -91,7 +91,7 @@ dynamodb.queryCount(
**Usage**

```js
import dynamodb from "Utils/dynamodb";
import dynamodb from "lesgo/utils/dynamodb";

const count = await dynamodb.queryCount(
"ActorsTable",
Expand All @@ -118,7 +118,7 @@ dynamodb.put(
**Usage**

```js
import dynamodb from "Utils/dynamodb";
import dynamodb from "lesgo/utils/dynamodb";

const data = await dynamodb.put("ActorTable", {
actorName: "Keanue Reaves",
Expand All @@ -142,7 +142,7 @@ dynamodb.update(
**Usage**

```js
import dynamodb from "Utils/dynamodb";
import dynamodb from "lesgo/utils/dynamodb";

const data = await dynamodb.update(
"ActorsTable",
Expand Down
34 changes: 17 additions & 17 deletions docs/database/rds-aurora.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ As such, specifically for RDS Proxy, you should make use of Lesgo's persistent c
// src/handlers/utils/ping.js

import middy from "@middy/core";
import httpMiddleware from "Middlewares/httpMiddleware";
import ping from "Core/utils/ping";
import db from "Utils/db";
import httpMiddleware from "lesgo/middlewares/httpMiddleware";
import db from "lesgo/utils/db";
import ping from "core/utils/ping";

const originalHandler = async (event) => {
await db.pConnect();
Expand All @@ -146,8 +146,8 @@ Should you want to handle the closing of the db connection yourself and without
// src/handlers/utils/ping.js

import middy from "@middy/core";
import ping from "Core/utils/ping";
import db from "Utils/db";
import db from "lesgo/utils/db";
import ping from "core/utils/ping";

const originalHandler = async (event) => {
await db.pConnect();
Expand Down Expand Up @@ -186,7 +186,7 @@ db.select(
**Usage**

```js
import db from "Utils/db";
import db from "lesgo/utils/db";

const data = await db.select(
"SELECT * FROM users WHERE is_deleted = :isDeleted",
Expand All @@ -211,7 +211,7 @@ db.selectFirst(
**Usage**

```js
import db from "Utils/db";
import db from "lesgo/utils/db";

const data = await db.selectFirst("SELECT * FROM users WHERE id = :id", {
id: 1,
Expand Down Expand Up @@ -240,7 +240,7 @@ db.selectPaginate(
**Usage**

```js
import db from "Utils/db";
import db from "lesgo/utils/db";

const data = await db.selectPaginate(
"SELECT * FROM users WHERE is_deleted = :isDeleted",
Expand Down Expand Up @@ -270,7 +270,7 @@ db.insert(
**Usage**

```js
import db from "Utils/db";
import db from "lesgo/utils/db";

const insertId = await db.insert(
"INSERT INTO users(username,email) VALUES (:username, :email)",
Expand All @@ -284,9 +284,9 @@ const insertId = await db.insert(
A much better approach to inserting records is to first validate the fields and then inserting it with `Utils/prepSQLInsertParams`.

```js
import prepSQLInsertParams from "Utils/prepSQLInsertParams";
import validateFields from "Utils/validateFields";
import db from "Utils/db";
import prepSQLInsertParams from "lesgo/utils/prepSQLInsertParams";
import validateFields from "lesgo/utils/validateFields";
import db from "lesgo/utils/db";

const validFields = [
{ key: "username", type: "string", required: true },
Expand Down Expand Up @@ -323,7 +323,7 @@ db.update(
**Usage**

```js
import db from "Utils/db";
import db from "lesgo/utils/db";

const insertId = await db.update(
"UPDATE users SET username=:username, email=:email, updated_at=now()) WHERE id=:id",
Expand All @@ -338,9 +338,9 @@ const insertId = await db.update(
As with insert, updatating an existing record is best done with `Utils/prepSQLUpdateParams`.

```js
import prepSQLUpdateParams from "Utils/prepSQLUpdateParams";
import validateFields from "Utils/validateFields";
import db from "Utils/db";
import prepSQLUpdateParams from "lesgo/utils/prepSQLUpdateParams";
import validateFields from "lesgo/utils/validateFields";
import db from "lesgo/utils/db";

const validFields = [
{ key: "username", type: "string", required: true },
Expand Down Expand Up @@ -380,7 +380,7 @@ db.query(
**Usage**

```js
import db from "Utils/db";
import db from "lesgo/utils/db";

const data = await db.query("SELECT * FROM users WHERE id = :id", {
id: 1,
Expand Down
Loading