Skip to main content

2 posts tagged with "code"

View All Tags

Octo in CJS

· One min read
Rahul Chaudhary
Maintainer
Banner

In Node, there are now two kinds of scripts: there are old-style CommonJS (CJS) scripts and new-style ESM scripts (aka MJS). CJS scripts use require() and module.exports; ESM scripts use import and export.

Octo exclusively supports ESM modules, requiring "type": "module" in package.json. In this article we will explore how to modify Octo imports to make them work in CJS.

import { App, LocalStateProvider } from '@quadnix/octo';
import { OctoAws, RegionId, S3StaticWebsiteService } from '@quadnix/octo-aws-cdk';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';

const __dirname = dirname(fileURLToPath(import.meta.url));

Take a look at how this code is written in ESM and compare it to the adjustments needed for CJS. Notice the use of IIFE in CJS to support Octo imports asynchronously.

Setting Up AWS Locally | A Comprehensive Guide

· 3 min read
Rahul Chaudhary
Maintainer
Banner

Introduction

Octo makes managing AWS infrastructure easier. But before you can run Octo scripts on your local machine, you'll need to set up AWS locally. This involves signing up for an AWS account, creating an IAM user (which controls access to AWS resources), generating security credentials, and configuring them on your machine. We're here to guide you through each step and help you kickstart your journey with Octo and AWS on your local development environment.