This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { DynamoDBClient } from "@aws-sdk/client-dynamodb"; | |
import { DynamoDBDocumentClient, GetCommand, PutCommand, ScanCommand } from "@aws-sdk/lib-dynamodb"; | |
/* | |
GetCommand används för att hämta en specifik Item i en Table. (AWS rekommenderar att man har allt i samma tabell.) | |
ScanCommand kan hämta hela innehållet i en tabell. Opraktiskt om man har mycket data. | |
PutCommand lägger till en ny Item. | |
UpdateItemCommand ändrar en Item. | |
DeleteCommand | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Exempel på användning: | |
import { ask } from './ask.ts' | |
let x: string = await ask('Vilken är din favoritfärg? ') | |
console.log('Du svarade: ' + x) | |
*/ | |
import readline from 'node:readline' | |
async function ask(query: string): Promise<string> { | |
const rl = readline.createInterface({ input: process.stdin, output: process.stdout, tabSize: 4 }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Feature: Musiksökning | |
Som en användare av musiktjänsten | |
Vill jag kunna söka efter musik | |
För att hitta musik jag gillar | |
Background: | |
Given att jag är inloggad på musiktjänsten | |
And att jag är på söksidan | |
Scenario: Söka efter musik med giltigt sökord |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Use this file in your project. | |
But first, create a Node project: | |
npm init -y | |
Then add a line to package.json: | |
"type": "module", | |
Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add your secrets here | |
CONNECTION_STRING=yes-here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Schema, model, connect, Mongoose } from 'mongoose' | |
// Animal is an interface describing animal objects | |
import { Animal } from './animal.js'; | |
const animalSchema = new Schema<WithId<Animal>>({ | |
_id: ObjectId, // from WithId | |
species: String, // from Animal | |
factoid: String, // from Animal | |
score: Number // from Animal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example produced 2024-05-13 | |
// vite.config.js | |
import { defineConfig } from 'vite' | |
import react from '@vitejs/plugin-react-swc' | |
// https://vitejs.dev/config/ | |
export default defineConfig({ | |
plugins: [react()], | |
server: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import the functions you need from the SDKs you need | |
import { initializeApp } from "firebase/app"; | |
import { getFirestore, collection, addDoc, getDocs, getDoc, doc, updateDoc, deleteDoc } from 'firebase/firestore/lite' | |
// Get this from Firebase Console | |
import { firebaseConfig } from "./firebaseConfig.js"; | |
// Initialize Firebase and get database | |
const app = initializeApp(firebaseConfig); | |
const db = getFirestore(app) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The Budget component uses "conditional rendering" to do | |
different things based on its props. What will each line | |
in the App component render? | |
*/ | |
const App = () => ( | |
<main> | |
<Budget value={5500} /> | |
<Budget value={240} /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A component is a function that returns JSX | |
const Aaa = () => ( | |
<div> | |
You can do any JSX in here | |
</div> | |
) | |
// Remember to export the component | |
// Most people have one component per file and use export default | |
export default Aaa |
NewerOlder