sapper | The next small thing in web development , powered by Svelte | Frontend Framework library
kandi X-RAY | sapper Summary
kandi X-RAY | sapper Summary
Sapper is a framework for building high-performance universal web apps. Read the guide or the introductory blog post to learn more.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of sapper
sapper Key Features
sapper Examples and Code Snippets
//server.js
import sirv from 'sirv';
import express from 'express';
import passport from 'passport';
import { Strategy } from 'passport-github';
import bodyParser from 'body-parser';
import session from 'express-session';
import sessionFi
const paths = {
it: {
'chi-siamo': 'about',
// others...
},
fr: {
// ...
},
// ...
};
server
.use(
compression({ threshold: 0 }),
(req, res, next) => {
const [, lang, ...parts] = req.url.split('/')
import * as sapper from '@sapper/app';
sapper.start({
target: document.querySelector('#sapper')
});
import * as sapper from './@sapper/server.mjs';
C:\Users\admin\project> npm run dev
> web_channel-mnp_om@0.0.1 dev C:\Users\admin\project
> sapper dev
✗ server
Unexpected token (1:63)
✗ client
Unexpected token (1:63)
(node:6220) UnhandledProm
Community Discussions
Trending Discussions on sapper
QUESTION
Port 3000 is occupied in my hosting server. Now I'm building a sveltekit app. When I use
...ANSWER
Answered 2022-Feb-22 at 21:11svelte-kit dev
and svelte-kit preview
are used for development and debugging purposes and should not be run for production builds.
when deploying to a server you run svelte-kit build
to generate the final site (in your case that should be located in ./buildit)
i don't think that you can statically specify the port being used, but you can provide it when launching the server using an environment variable.
(i am using @sveltejs/adapter-node, so this might be different for other adapters)
QUESTION
I have been trying to integrate stripe elements on my sapper framework.
I am using this library svelte-strip-js, all steps work fine but I have started to see these issues continuously on my console
...ANSWER
Answered 2022-Feb-17 at 23:23It appears that this was a known configuration issue on Stripe’s end and a fix was deployed. You shouldn’t be seeing these errors anymore. From what I can tell from Stripe’s discord server threads regarding these errors, r.stripe.com
is just for tracking metrics so it should not have any impact on the ability to make payments.
QUESTION
I have a stripe elements integration on my project. I use sapper on front end and ruby on the backend.
I followed the tutorial to setup the server to generate payment intent using stripe private key and front end to show stripe embeddable UI using stripe publish key, everything works fine the only problem is as follows.
Once a payment is done using test card details I get the following error
Refused to load the image 'https://hooks.stripe.com/img/favicon.png' because it violates the following Content Security Policy directive: "img-src data: https://q.stripe.com".
ANSWER
Answered 2022-Feb-15 at 20:34The issue that you describe is related to the CSP and how it is configured for your project. Stripe has documentation related to the CSP describing all the required directives https://stripe.com/docs/security/guide#content-security-policy. It requires img-src
directive to allow loading of the content from https://*.stripe.com
while your current directive permits only data:
and https://q.stripe.com
.
Extending your current directive with the requirements from Stripe should solve the issue.
QUESTION
This question will need someone from vercel team or sveltekit team as it is related to pwa app that I published to vercel: 1- I placed a minifest1.js file in the "static" folder 2- I placed testserviceworker.js file in the "SRC" folder.
When I run my app locally using my laptop by "npm run build" and "npm run preview", vite registers my serviceworker, my cache is populated and the app is installable as pwa.
When I deploy the same code to vercel, vite fails to register the serviceworker. To experiment I added the serviceworker file to the static folder and added a register button in index.svelte to register the file manully when I press the button.
When I press the button, the serviceworker is registered, I'm able to verify it in dev tools, application tab, cache and able to install my app but my lighthouse report showing pwa part as failed.
So my question is regarding vite registering serviceworker by default upon starting the site. Do I need to add a function in load or onMount with "navigator.serviceWorker.register('testserviceworker.js" or there is some kind of magic configuration in vercel or svelte.config.js to point vite to where the serviceworker.js so it register it upon starting the app?
I added the files for manifest and serviceworker here but I don't think they're relative to my question as it is a configuration issue not code issue:
manifest file:
...ANSWER
Answered 2022-Feb-11 at 22:40I ended with registeration in the onMount. Now when the app is loaded, the serviceworker is registered and pwa is installable. It passed the lighthouse checks. All green.
Here is the code for onMount:
QUESTION
After initiating a skeleton project from sveltekit app. my index has a form :
...ANSWER
Answered 2022-Feb-05 at 17:47You're right that the PR changed how you access the body. Now to access the request body in your endpoint you have to use:
QUESTION
So I can't figure a way to pass a variable up in my __layout
variable from the component displayed in the .
I tried a few things, using bind:
or let:
on the slot but it doesn't work. I get 'myvar' is not a valid binding
or cannot have directives
.
I also tried to export or not the variable on the layout, but I really cannot make it work...
Here is what I have:
...ANSWER
Answered 2022-Jan-31 at 16:35I give below an example with named slots, also unnamed ->
In Slot.svelte
QUESTION
I am creating an application in Svelte Sapper. I have a routes/account/login.js
API route where I am trying to use mysql2. The route itself works (I checked with Postman), but as soon as I import mysql, the server crashes and an error appears:
ANSWER
Answered 2021-Sep-20 at 16:40I found a solution. I had to create a @lib
folder in the src/node_modules
folder and there file eg. db.js
. In that file instead of import
you need to use require()
! and then you have to export the function that connects to the database. and then you can import that in the path
QUESTION
it is my first time with tensorflow and I have problem that I can't solve. I found a lot of same problems on stackoverflow, but they don't help me. (probably I just don't know how use it correctly) I have a model, that trained by this algorithm
...ANSWER
Answered 2021-Jun-20 at 11:23There is a problem with your input shape obviously.
The architecture of your model is as below. So the input shape should be (1,400,400,3).
In the function prepare
that feeds the data to the network, the output shape is (400,400,1). And that is why you get an error.
QUESTION
I have written a few apps using svelte and sapper and thought I would give sveltekit a go. All in all it works, but I am now running into the issue of registering a worker on ther server.
Basically I am trying to add socket.io to my app because I want to be able to send and receive data from the server. With sapper this wasn't really an issue because you had the server.js
file where you could connect socket.io to the polka/express server. But I cannot find any equivalent in sveltekit and vite.
I experimented a bit and I can create a new socket.io server in a route, but that will lead to a bunch of new problems, such as it being on a separate port and causing cors issues.
So I am wondering is this possible with sveltekit and how do you get access to the underlying server?
...ANSWER
Answered 2021-May-20 at 08:12You cannot connect to a polka/express server because depending on the adapter you choose there can be no polka/express server used - if you deploy to a serverless platform for example. Sockets for serverless are not so easy to implement and their implementation depend on the provider.
You are raising an important concern but right now I'm afraid this is not possible - someone corrects me if I'm wrong.
What you still can do is to write your front with SvelteKit, build it as a static/SPA/node application and then use your build from your own polka/express server. You lose the swift development experience offered by SvelteKit though, since your development will be parted in two: first the client, then the server.
QUESTION
I created an base app though the sveltekit cli commands. The options I chose are scss and typescript. At soon as I started the application for a split second I saw unstyled html. This happens every time and with every project i create. I did some testing and it seems like the css(app.scss) is loaded after the html(localhost). Another this that seems consistent is that is happens every time i reload the page, but not with navigating. This indicates that it is probably server-side. In my mind the html and css should load in the same file, though SvelteKit might have a different approach.
I had the same issue with Sapper and solved that. But I forgot how I fixed it. Also with the new SvelteKit setup many things are different. Do you guys know how to fix this?
Thanks in advance
...ANSWER
Answered 2021-Apr-10 at 09:56SvelteKit does not bundle everything together during development mode and injects support for HMR. This may result in flashes of unstyled content.
The flashes of unstyled content should go away in production mode, when you deploy with an adapter.
This stock SvelteKit template does not flash unstyled content. The only change was changing the adapter from the node adapter to the static adapter so it could be hosted on Netlify. (I have also confirmed with the Netlify adapter, so it's not a difference between static and dynamic.)
How to test with the stock SvelteKit template:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install sapper
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page