rustup update
rustup target add wasm32-unknown-unknown --toolchain nightly
rustc +nightly --target wasm32-unknown-unknown -O --crate-type=cdylib add.rs -o add.big.wasm
wasm-gc add.big.wasm add.wasm
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
( | |
account_id bigint encode bytedict, | |
account_name varchar(100) encode ztsd, | |
account_update_date date, | |
primary key (account_id) | |
) | |
distsyle all | |
sortkey(account_id) | |
; |
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
[ | |
{ | |
"name": "account_id", | |
“type”: “STRING”, | |
“mode”: “NULLABLE” | |
}, | |
{ | |
“name”: “account_name”, | |
“type”: “INT64”, | |
“mode”: “NULLABLE” |
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
require('dotenv').config(); | |
const express = require('express'); | |
const bodyParser = require('body-parser'); | |
const app = express(); | |
const port = process.env.PORT || 5000; | |
// use body parser to get data from POST requests | |
app.use(bodyParser.json()); | |
app.use(bodyParser.urlencoded({ extended: true })); |
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
const axios = require("axios"); | |
// Configuring the path to read the environment variable file, .env, to get the weather api key | |
require('dotenv').config({path: "./../../../.env"}); | |
const baseUrl = "http://api.openweathermap.org/data/2.5/weather"; | |
class Weather { | |
/** |
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 express's router to route all our API endpoints | |
const express = require('express'); | |
const router = express.Router(); | |
// Use the weather class we made in ./weather.js to call our method that will get the weather data from the api | |
const Weather = require("./weather"); | |
// GET Request - statically get the weather data from the weather api | |
router.get("/weather", async (req, res) => { | |
let weather = new Weather(); |
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
const mongoose = require('mongoose'); | |
// use body parser to get data from POST requests | |
... | |
// Use API routes from the api folder | |
... | |
// Connect to Mongo | |
mongoose.connect(process.env.DB, { |
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
const mongoose = require('mongoose'); | |
const WeatherSchema = new mongoose.Schema({ | |
zip: Number, | |
coord: { | |
lon: Number, | |
lat: Number | |
}, | |
weather: [ | |
{ |
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
const WEATHER = require("../models/Weather"); | |
... | |
class Weather { | |
... | |
/** | |
* Saves the weather data using the zipcode as the unique identifier | |
* If it already exists, replace, if not, then add. |
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
... | |
// POST Request - dynamically get the weather data based on request body | |
router.post("/weather", async (req, res) => { | |
... | |
}); | |
// POST Request - get the weather data from the api, save it to mongo, then return the data back | |
router.post("/weatherMongo", async(req, res) => { | |
const {zipCode, tempMetric} = req.body; |
OlderNewer