import axios from 'axios';
import { task } from '@ampt/sdk';
const fetchData = async () => {
const response = await axios.get('https://api.my-saas.com');
}
const myTask = task('Fetch Sample Data', fetchData)
myTask.every("1 hour")
import { data } from "@ampt/data";
export default function HomePage({ users }) {
return (
<div classname="root">
<h1>Welcome to Ampt!</h1>
{users?.map((user) => (<p key={user.id}>{user.name}</p>))}
</div>
);
}
export async function getServerSideProps() {
const result = (await data.get("user:*", true));
return {
props: {
users: result.items.map(({ value }) => value)
},
};
}
import { http } from "@ampt/sdk";
import fastify from "fastify";
const fastifyApp = fastify();
fastifyApp.get("/hello", (req, res) => {
res.send("Hello fastify!");
});
http.node.use("/api", fastifyApp);
import { defineConfig } from "astro/config";
import ampt from "@ampt/astro";
import svelte from "@astrojs/svelte";
export default defineConfig({
output: "server",
integrations: [ampt(), svelte()],
});
import { http } from "@ampt/sdk";
import express from "express";
const expressApp = express();
expressApp.get("/hello", (req, res) => {
res.send("Hello express!");
});
http.node.use("/api", expressApp);
const { data } = require('@ampt/data');
module.exports = async function () {
return async data.get('posts:*');
};