question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[VPS Frameworks] TypeScript DX

See original GitHub issue

Do typed custom exports/hooks cover all use cases?

Do we forsee shorctomings that we should fix before releasing 0.4?

Custom Exports:

// /pages/_default.page.ts

import type { Config } from 'vilay'

export const config: Config = {
   graphqlEndpoint: 'https://api.star-wars.com/_graphql'
}

Custom Hooks:

// /pages/star-wars.page.ts

import type { GetPageMeta, FilterData } from 'vilay'

type Movies = {
  title: string,
  releaseDate: Date
}

export const getPageMeta: GetPageMeta<Movie> = async movie => {
  const { title } = movie
  return {
    // Determines the `<title>` tag
    title,
    description: `Everything you ever wanted to know about the Star Wars Movie "${title}".`
  }
}

// Filter data to reduce KBs sent to the browser
type MoviesData = Movie & {
  much: string,
  more: string,
  data: string
}
export const filterData: FilterData<MoviesData, Movies> = async function filterData(moviesData) {
  const movies = moviesData.map(m => ({ title: m.title, releaseDate: m.releaseDate }))
  return movies
}

Note that how the user doens’t access pageContext; the framework fully abstracts pageContext away.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
brilloutcommented, May 2, 2022

With multiple define* functions:

// /pages/hello.page.tsx

import { definePage } from 'vilay'

export default definePage({
  getQueryVariables(routeParams) {
    return { ...routeParams, first: 10 },
  },
  // ...
})

export function Page() {
  return <>Hello</>
}
// /pages/_default.page.ts

import { defineConfig } from 'vilay'

export default defineConfig({
  graphqlEndpoint: 'https://foo.bar/graphql',
  // ...
})
1reaction
brilloutcommented, May 4, 2022

Default exporting released with 0.4.0-beta.16.

I guess we can close this then.

Let me know if you have other concerns about TS DX.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 5 TypeScript Frameworks (2022)
Top 5 TypeScript Frameworks · Start Learning Backend Dev. Now · Nest.js Framework · FeatherJS Framework · LoopbackJS Framework · Get free NODEJS...
Read more >
Reference TypeScript Definitions - DevExtreme - DevExpress
You can find the file with TypeScript definitions for DevExtreme in the DevExtreme zip archive or in the folder where you have installed...
Read more >
Which framework should I choose for my project? - OVH
The frameworks are designed to help you structure and automate your projects, from website development to creating complex systems.
Read more >
functions-framework-nodejs/typescript.md at master - GitHub
This guide is an example of how to develop a function in Typescript with the Functions Framework. Create a new Node.js project using...
Read more >
tRPC - Move Fast and Break Nothing. End-to-end typesafe ...
Move Fast and Break Nothing. End-to-end typesafe APIs made easy. Experience the full power of TypeScript inference to boost productivity
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found