Security News
vlt Debuts New JavaScript Package Manager and Serverless Registry at NodeConf EU
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
npm install -g elm-spa
elm-spa init <directory>
Create a new elm-spa app in the <directory>
folder specified.
examples:
elm-spa init .
elm-spa init my-app
elm-spa add <static|sandbox|element|full> <name>
Create a new page of type <static|sandbox|element|full>
with the module name <name>.
examples:
elm-spa add static Top
elm-spa add sandbox Posts.Top
elm-spa add element Posts.Id_Int
elm-spa add full SignIn
elm-spa build [dir]
Create "Generated.Route" and "Generated.Pages" modules for
this project, based on the file names in "src/Pages"
Here are more details on how that works:
https://www.npmjs.com/package/elm-spa#naming-conventions
examples:
elm-spa build
elm-spa build ../some/other-folder
elm-spa build ./help
the elm-spa build
command is pretty useful, because it
automatically generates Routes.elm
and Pages.elm
code for you,
based on the naming convention in src/Pages/*.elm
Here's an example project structure:
src/
└─ Pages/
├─ Top.elm
├─ About.elm
├─ Posts/
| ├─ Top.elm
| └─ Post_Int.elm
└─ Authors/
└─ Author_String/
└─ Posts/
└─ Post_Int.elm
When you run elm-spa build
with these files in the src/Pages
directory, elm-spa can
automatically generate routes like these:
Page | Route | Example |
---|---|---|
Top.elm | / | - |
About.elm | /about | - |
Posts/Top.elm | /posts | - |
Posts/Id_Int.elm | /posts/:id | /posts/123 |
Authors/Author_String/Posts/PostId_Int.elm | /authors/:author/posts/:postId | /authors/ryan/posts/123 |
Top.elm
represents the top-level index in the folder.User_Int.elm
defines a dynamic parameter named user
that should be an Int
.User_Int
can also be a folder name, supporting nested dynamic routes.These dynamic parameters are available as Params
for the given page.
Here are some specific examples from the routes above:
module Pages.About exposing (..)
type alias Params =
()
module Pages.Posts.Id_Int exposing (..)
type alias Params =
{ post : Int
}
module Pages.Authors.Author_String.Posts.PostId_Int exposing (..)
type alias Flags =
{ author : String
, postId : Int
}
These Params
are automatically passed into the init
function, along with
other information like the query parameters and complete raw Url
value.
FAQs
single page apps made easy
The npm package elm-spa receives a total of 307 weekly downloads. As such, elm-spa popularity was classified as not popular.
We found that elm-spa demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt introduced its new package manager and a serverless registry this week, innovating in a space where npm has stagnated.
Security News
Research
The Socket Research Team uncovered a malicious Python package typosquatting the popular 'fabric' SSH library, silently exfiltrating AWS credentials from unsuspecting developers.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.