Skip to content

Folder Structure & Best Practices #183

@jycouet

Description

@jycouet

First off, thank you for sv, is was a nice surprise!

I'm about to start a community template, but before starting I would like to know if you have already some "rules" in mind? Or it will come with doing ?


1/ hooks.server.ts
What about enforcing sequence and importing handle from the corresponding template?
I feel that any application will need this sequence and it would probably ease the installation of other template.

Example with auth:

import { sequence } from '@sveltejs/kit/hooks';
import { handleAuth } from '$lib/server/auth.ts';

export const handle= sequence(handleAuth);

2/ Folders structure
./src/lib/server/auth.ts vs ./src/server/auth.ts vs ./src/modules/auth/server.ts
Of course, everyone is able to do what he want after, but I'm wondering if we could put people in the right track from the start?
If we start to have a lot of community integration, having the same style would also be beneficial.

I'm using this structure in my app and find it quite convenient

src
  lib                
    assets
      logo.svg
    ui
      Button.svelte
  modules          
    auth
      hook.server.ts
      server.ts
      ui
        index.ts
        Login.svelte
  routes
    +layout.svelte
    +page.svelte

Like this, I also use $lib and $modules


Let me know what do you think, I'll be happy to help building this view.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions